openmmtools.utils.Timer¶
-
class
openmmtools.utils.Timer[source]¶ A class with stopwatch-style timing functions.
Examples
>>> timer = Timer() >>> timer.start('my benchmark') >>> for i in range(10): ... pass >>> elapsed_time = timer.stop('my benchmark') >>> timer.start('second benchmark') >>> for i in range(10): ... for j in range(10): ... pass >>> elsapsed_time = timer.stop('second benchmark') >>> timer.report_timing()
Methods
partial(benchmark_id)Return the elapsed time of the given benchmark so far. report_timing([clear])Log all the timings at the debug level. reset_timing_statistics([benchmark_id])Reset the timing statistics. start(benchmark_id)Start a timer with given benchmark_id. stop Methods
__init__()x.__init__(…) initializes x; see help(type(x)) for signature partial(benchmark_id)Return the elapsed time of the given benchmark so far. report_timing([clear])Log all the timings at the debug level. reset_timing_statistics([benchmark_id])Reset the timing statistics. start(benchmark_id)Start a timer with given benchmark_id. stop(benchmark_id)-
report_timing(clear=True)[source]¶ Log all the timings at the debug level.
Parameters: - clear : bool
If True, the stored timings are deleted after being reported.
Returns: - elapsed_times : dict
The dictionary benchmark_id : elapsed time for all benchmarks.
-