Skip to main content

Simple Python code metering library.

Project description

ticktock

Simple Python code metering library.


ticktock is a minimalist library to profile Python code: it periodically displays timing of running code.

Quickstart

First, install ticktock:

pip install py-ticktock

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:

from ticktock import tick

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

This will print the timing of the lines 3 to 5 in your code as so:

⏱️ [3-5] 50us count=1

How is ticktock different?

ticktock becomes really useful when you are trying to time code that is called multiple times.

Rather than printing a new line each time the code is visited, ticktock tracks the times and only prints them every couple of seconds.

ticktock's output is compact and readable, regardless of how many times you run through the code you are timing, or where this code is.

As an example, the following code:

from ticktock import tick

for _ in range(1000):
    clock = tick()
    # do some work
    clock.tock()

Will result in a single, continuously updated line of output showing you the average time and how many times it was called so far:

⏱️ [4-6] 50us count=1000

Documentation

Checkout the documentation for a complete manual.

ticktock is actively being developed, be sure to submit issues or pull requests with ideas!

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.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file py_ticktock-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_ticktock-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for py_ticktock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14a9b95527124fb006898f1ce6e98e17e701e0a080567b61a91d3b63f9a1d38f
MD5 c3199829e459fa0f5e636a23629fbab3
BLAKE2b-256 65019c95b57fcc45942acbb8e1bf56779aec6142d5da766ee8ff9d7ae6f1ddac

See more details on using hashes here.

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