delu.Timer.__enter__#

Timer.__enter__()[source]#

Measure time within a context.

The method Timer.run is called regardless of the current state. On exit, Timer.pause is called.

See also

Timer.__exit__

Example

..testcode:

import time
with Timer() as timer:
    time.sleep(0.01)
elapsed = timer()
assert elapsed > 0.01
time.sleep(0.01)
assert timer() == elapsed  # the timer is paused in __exit__
Return type

delu._utils.Timer