Skip to main content

<Enter a one-sentence description of this project here.>

Project description

A context manager for timing code.

Typical use:

# Create a Stopwath with and end message string and printed 3 digits
with Stopwatch("time 5 times 'sleep(1)': ",ndigits=3) as tmr:
    for i in range(5):
        sleep(1) # supposing there isn't anything more useful to oo ;-)
        print(i,tmr.timelapse()) # time since last call to timelapse()

print(tmr.time) # the total time

Running this code yields:

0 1.004
1 1.004
2 1.004
3 1.004
4 1.004
time 5 times 'sleep(1)': 5.02 s
5.02

Features

  • TODO

Project details


Download files

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

Source Distribution

et-stopwatch-0.1.0.tar.gz (3.0 kB view hashes)

Uploaded source

Built Distribution

et_stopwatch-0.1.0-py3-none-any.whl (3.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page