Skip to main content

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

Project description

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 │
└─────────────────────┴───────┴──────────┴──────────┴──────────┘

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

livetimer-0.2.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

livetimer-0.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file livetimer-0.2.0.tar.gz.

File metadata

  • Download URL: livetimer-0.2.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.7 Windows/10

File hashes

Hashes for livetimer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 48b97f376fb47c5d30f92e65d040f37bfc38bf2be5ac609006fac4d57fc0be45
MD5 16fbac58a4e088500e3e4f6f27359bff
BLAKE2b-256 ca5f716e7fa447b3c8fe3ff13e5d7d53c553af68e2d6dd689f169f06b6f4a73c

See more details on using hashes here.

File details

Details for the file livetimer-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: livetimer-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.7 Windows/10

File hashes

Hashes for livetimer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d10cb02a92e4726d5b5a031e43d01eb289f7cc7f5cfcc7abf4a51523284ac1dd
MD5 a84d46fa6e4402a3bfa2ffb819d12b82
BLAKE2b-256 fd5f3710cab55be7e59921d54da7fcf6d8a2862a55c96459688c22321074e702

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