Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Easy-to-use timer for tracking runtimes

Project description

timer

Easy-to-use timer for tracking runtimes.

pip install sometimer

Examples

Main functionality: summary function

from sometimer 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
               -duration-     -start-
start                           0.00s
checkpoint_0:       2.36s       0.10s      
useful-name:        0.41s       2.46s
victory lap :      12.01s       2.87s
end                            14.87s


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:

from sometimer import time_this_method

@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
                        -duration-     -start-
start:                       0.00s       0.00s
heavy_preprocessing:         0.00s      25.10s
more-descriptive-name:      25.10s      13.01s
end:                        38.10s'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sometimer, version 0.1.10
Filename, size File type Python version Upload date Hashes
Filename, size sometimer-0.1.10-py3-none-any.whl (12.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page