Timing class for measuring elapsed time and average elapsed time.
Project description
noiftimer
Simple timer class to track elapsed time.
Install with:
pip install noiftimer
Usage:
>>> from noiftimer import Timer, time_it >>> import time
Timer object
>>> def very_complicated_function(): ... time.sleep(1) ... >>> timer = Timer() >>> for _ in range(10): ... timer.start() ... very_complicated_function() ... timer.stop() ... >>> print(timer.stats) elapsed time: 1s 1ms 173us average elapsed time: 1s 912us >>> timer.elapsed 1.001173496246338 >>> timer.elapsed_str '1s 1ms 173us' >>> timer.average_elapsed 1.0009121656417848 >>> timer.average_elapsed_str '1s 912us'
time_it decorator (executes the decorated function 10 times)
>>> @time_it(10) ... def very_complicated_function(): ... time.sleep(1) ... >>> very_complicated_function() very_complicated_function average execution time: 1s 469us
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
noiftimer-2.4.1.tar.gz
(59.9 kB
view hashes)
Built Distribution
Close
Hashes for noiftimer-2.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c70a2e0d95fa1b4a1fe6c28f4badf8286714cde7cbbf3d3fe68aa7f8e4c07789 |
|
MD5 | 354277f647abf5a76d6fa64064755a2d |
|
BLAKE2b-256 | e4242c6359a9f9d8b3779df4ca38fc0f7ca2272d55e6c175d03a27e508d86b93 |