debug

class Timer(name: AnyStr | None = None)

Context manager for timing code snippets.

Parameters:

name (str) – if specified, print it together with the elapsed time when exiting the context

Variables:

time (float) – elapsed time (only available after exiting the context)

Example:

>>> with Timer("100000 divisions"):
...     result = [i / 42 for i in range(100000)]
...
    4112.60 us [100000 divisions]