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  
__init__()[source]

x.__init__(…) initializes x; see help(type(x)) for signature

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)
partial(benchmark_id)[source]

Return the elapsed time of the given benchmark so far.

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.

reset_timing_statistics(benchmark_id=None)[source]

Reset the timing statistics.

Parameters:
benchmark_id : str, optional

If specified, only the timings associated to this benchmark id will be reset, otherwise all timing information are.

start(benchmark_id)[source]

Start a timer with given benchmark_id.