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.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: livetimer-0.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 440991ecf47f221e978e654f35216efb21daae7b4b9d1971eaeb1809bdf19c6d
MD5 712d50d53bb933e92afa8da79bbe92e6
BLAKE2b-256 279f4f882b2ea09e766b8351ab58424878cbd36caad73f2b96b0973f08391d67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: livetimer-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89d4f2dec2ff97cd03c7bdfec0f8a6fbaba484f10879dd452bd150671a384a4b
MD5 4947f2b2b0b041dbdc3149d99a19f8ea
BLAKE2b-256 ee0f570a0b00edc9294c45ccc0756db041e0ecec99e09cdc830938700189b443

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