ticking
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
Quick in-program profiling:
>>> with ticking.profiled('testprofile.prof'):
... time.sleep(1.0)
...
>>> import pstats
>>> pstats.Stats('testprofile.prof').print_stats()
Wed Jun 8 11:21:38 2016 testprofile.prof
5 function calls in 1.001 seconds
Random listing order was used
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
1 1.001 1.001 1.001 1.001 {built-in method sleep}
1 0.000 0.000 0.000 0.000 /usr/lib/python3.4/contextlib.py:63(__exit__)
1 0.000 0.000 0.000 0.000 {built-in method next}
1 0.000 0.000 0.000 0.000 /home/marc/Documents/github.com/mbr/ticking/ticking.py:137(profiled)
Metadata
Release files for ticking 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ticking-0.4.0.tar.gz | 4.0 kB | Without provenance | Details for ticking-0.4.0.tar.gz |
Release files / ticking-0.4.0.tar.gz
| Download URL | ticking-0.4.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5c1a72a41e2afc23225dfad6aaba8eacc3d1269cc6d40a676fb7192022eac1a
|
|
BLAKE2b-256 checksum How to use checksums |
7dcbbba999ddc712c36f3cdba035a076d32da2e935afd709bee35228c5bd5550
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ticking 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.