Skip to main content

A small timing utility library, handling framerates and rough benchmarks.

Project description

Useful tools when dealing with clocks for timing and benchmarking. Will use a different method for retrieving accurate, monotonic clock values (see source for detail).

Tested on Python 2.7 and 3.3+. The latter is recommended because the time module contains much better access to OS timing functions.

Examples

Simple framerate-limiter:

>>> import ticking
>>> for frame, t in ticking.Clock(0.5):
...   print(frame, t)
...
1 0.5
2 1.0
3 1.5
...

After dropping a frame, the clock is aligned again:

>>> import time
>>> for frame, t in ticking.Clock(0.5):
...   print(frame, t)
...   time.sleep(0.8)  # drop a frame
...
1 0.5
3 1.5
5 2.5

Measuring time:

>>> with ticking.Stopwatch('Demonstration') as sw:
...   time.sleep(1.3)
...
>>> sw.total
1.3013252970049507
>>> print(sw)
Demonstration: took 1.30s

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

ticking-0.3.0.tar.gz (3.2 kB view hashes)

Uploaded Source

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