amtTimer

A simple class to measure code performances.


License
Apache-2.0
Install
pip install amtTimer==1.0.0

Documentation

amtTimer

Package license Python 3.7+ Latest version released on PyPI Travis build Tests coverage


amtTimer is a Python 3 package that provides a class to measure code performances.

Time points are tagged with a name and multiple measurements of the same time point are aggregated. Statistics on measurements can be built and used for analysis.


Basic Usage

Install with pip:

pip install amtTimer

Import the Timer and TimerSingleton class in your python code, and instanciate it

from amtTimer import Timer, TimerSingleton

myTimer = Timer()

The TimerSingleton class can be used to create a global Timer object.

Adding a new time point can be done inside or outside a context manager.

# new time point with context manager
with myTimer("point_1"):
    # do something

# new time point outside a context manager
point_2 = myTimer("point_2")
point_2.start()
# do something
point_2.stop()

Retrieving the list of time points already defined:

for name in myTimer.names():
    print(f"Time Point {name} is defined")

Statistics are provided by the amtStats module. The values for a particular time point can be obtained with:

results = myTimer.stats("point_1")

Tests

Run tests:

$ tox

License

This package is released under the Apache License 2.0. See the bundled LICENSE file for details.