Skip to main content

Simple Python code metering library.

Project description

ticktock

Simple Python code metering library.


ticktock is a minimalist library to view Python time performance of Python code.

First, install ticktock:

pip install py-ticktock

Then, anywhere in your code you can use tick to start a clock, and tock to register the end of the snippet you want to time:

t = tick()
# do some work
t.tock()

Even if the code is called many times within a loop, measured times will only periodially (2 seconds by default):

import time
from ticktock import tick

for _ in range(1000):
    t = tick()
    # do some work
    time.sleep(1)
    t.tock()

You can create multiple independent ticks, which will appear as two separate clocks:

for _ in range(1000):
    t = tick()
    # do some work
    time.sleep(1)
    t.tock()

    t = tick()
    # do some other work
    time.sleep(0.5)
    t.tock()

Ticks can share a common starting point:

for k in range(1000):
    t = tick()
    # do some work
    time.sleep(1)
    if k % 2 == 1:
        time.sleep(1)
        t.tock()
    else:
        t.tock()

Project details


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

py_ticktock-0.0.1-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page