Easy-to-use timer for tracking runtimes
Project description
timer
Easy-to-use timer for tracking runtimes.
Examples
Main functionality: summary function
from timer import timer
# Main functionality is the summary function:
timer.new_checkpoint()
do_stuff()
timer.new_checkpoint(name='useful-name')
do_other_stuff()
...
summary = timer.summary()
print(summary)
timer summary
-start- -duration-
start: 0.000s 0.100s
checkpoint_0: 0.100s 2.305s
useful-name: 2.405s 0.410s
victory lap: 2.815s 12.001s
end: 14.816s
timer.__call__()
returns a one-liner
timer()
>>> 'timer: 0.202s'
# and with an active checkpoint:
timer()
>>> 'timer: 0.303s checkpoint_0: 0.050s'
@time_this_method
decorator to avoid clutter
Some functions are always heavy (e.g. load, data preprocessing, data augmentation) and might be useful to time:
@time_this_method
def heavy_preprocessing(data):
pass
@time_this_method(name='more-descriptive-name')
def inefficient_method(data):
pass
when run, yields:
heavy_preprocessing(data)
inefficient_method(data)
timer.summary()
>>> 'timer summary
-start- -duration-
start: 0.000s 0.000s
heavy_preprocessing: 0.000s 25.101s
more-descriptive-name: 25.101s 13.001s
end: 38.102s'
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for sometimer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16b7e1bc9ea945aa3ccb0d67c42dfe0ac0cc24cbd6945d5b8b6c3360c6c2ebc9 |
|
MD5 | e8dec49c623353378a36b9d847089347 |
|
BLAKE2b-256 | 73fecda8bff99beab0942540aa8ad0a92ccb1b0c88925f6bc83f32fbb95798aa |