Skip to main content

LiveTimer

A Python module to log multiple points in a repeating operation to get live statistics.

Upfront Performance Notice

This module was not designed with per-cycle performance in mind. It was designed to time IO-bound operations with millisecond precision, and has not been benchmarked or optimized for highly performant applications. You are welcome to submit pull requests that would improve performance.

Usage

This example can be found in demo.py.

>> with RichTimer().start as timer:
>>     for _ in range(100):
>>         with timer.cycle as cycle:
>>             time.sleep(randint(1, 8) * 0.001)
>>             cycle.log("Logpoint: 10-80ms")
>>             time.sleep(randint(1, 2) * 0.001)
>>             cycle.log("Logpoint: 10-20ms")
>>             time.sleep(0.1)
>>             cycle.log("Logpoint: 100ms")

Output:

┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┓
┃ Metric              ┃ Total ┃ Avg      ┃ Min      ┃ Max      ┃
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━┩
│ Count               │ 100   │          │          │          │
│ Time per Iteration  │       │ 0.107448 │ 0.102287 │ 0.113916 │
│ - Logpoint: 10-80ms │       │ 0.004728 │ 0.001104 │ 0.010578 │
│ - Logpoint: 10-20ms │       │ 0.001943 │ 0.001042 │ 0.003702 │
│ - Logpoint: 100ms   │       │ 0.100768 │ 0.100067 │ 0.109139 │
└─────────────────────┴───────┴──────────┴──────────┴──────────┘

Release files for LiveTimer 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LiveTimer 0.2.0
File Size Uploaded
livetimer-0.2.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for LiveTimer 0.2.0
File Interpreter ABI Platform
livetimer-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / livetimer-0.2.0.tar.gz

Download URL livetimer-0.2.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
48b97f376fb47c5d30f92e65d040f37bfc38bf2be5ac609006fac4d57fc0be45
BLAKE2b-256 checksum
How to use checksums
ca5f716e7fa447b3c8fe3ff13e5d7d53c553af68e2d6dd689f169f06b6f4a73c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.7 Windows/10

Release files / livetimer-0.2.0-py3-none-any.whl

Download URL livetimer-0.2.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d10cb02a92e4726d5b5a031e43d01eb289f7cc7f5cfcc7abf4a51523284ac1dd
BLAKE2b-256 checksum
How to use checksums
fd5f3710cab55be7e59921d54da7fcf6d8a2862a55c96459688c22321074e702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.7 Windows/10

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page