(label, printon=True)
Context manager that times and logs execution.
Context manager that times and logs execution.
Context manager that times and logs execution .
def timing(label, printon=True):
  """Context manager that times and logs execution."""
  if printon:
    print("enter %s" % label)
  start_time = time.time()
  yield
  time_taken = (time.time() - start_time) / 60.0
  if printon:
    print("exit  %s (%.3fmin)" % (label, time_taken))
def timing ( label , printon = True ) : if printon : print ( "enter %s" % label ) start_time = time . time ( ) yield time_taken = ( time . time ( ) - start_time ) / 60.0 if printon : print ( "exit  %s (%.3fmin)" % ( label , time_taken ) )