Skip to main content

Lightweight timing utilities for performance diagnostics

Project description

yumeow-timer

Lightweight timing utilities for optional performance diagnostics.

Installation

pip install yumeow-timer

Usage

Basic Timer

from yumeow_timer import Timer

timer = Timer()
for i in range(1000):
    # do something
    timer.add()

print(timer)  # Timer(time=1.23 s, count=1.00 kiter, pace=1.23 ms/iter, speed=813 iter/s)
print(timer.to_str('pace'))  # 1.23 ms/iter

NamedTimer (Multiple Categories)

from yumeow_timer import NamedTimer

timer = NamedTimer()
for i in range(1000):
    if i % 2 == 0:
        timer.add("even")
    else:
        timer.add("odd")

print(timer)  # 1.23 ms/iter (even=1.23 ms/iter[50%]; odd=1.23 ms/iter[50%])
print(timer.to_str('pace', mode_of_detail='pace', mode_of_percent='by_count'))

ParallelTimer (Shared Time)

from yumeow_timer import ParallelTimer

timer = ParallelTimer()
for i in range(1000):
    timer.add("process", n=1)
    timer.add("render", n=1)

print(timer)  # Shows shared time with separate counts

Humanize Functions

from yumeow_timer import humanize_time, humanize_count, humanize_pace, humanize_speed

print(humanize_time(3661))      # 1.02 h
print(humanize_count(1500))     # 1.50 kiter
print(humanize_pace(0.00123))   # 1.23 ms/iter
print(humanize_speed(813))      # 813 iter/s

API Reference

Timer

Basic timer that tracks time and count.

  • add(n=1, by="increment") - Add count and elapsed time
  • clear(reset_last_add_time=False) - Reset timer
  • to_str(mode="pace") - Get human-readable string
  • Properties: time, count, pace, speed

NamedTimer

Extends Timer to track multiple named categories with separate time tracking.

ParallelTimer

Extends Timer to track multiple named categories with shared time.

License

MIT License - See LICENSE file for details.

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

yumeow_timer-0.2.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yumeow_timer-0.2.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yumeow_timer-0.2.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for yumeow_timer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 08cae9f9c2dacab59faf85727150ac1c57ea569e326777835cfb4543ddd1fd4b
MD5 0818bf948ad7fa1541b72a5c8f9ab610
BLAKE2b-256 7a2d2c641360e28b1d0cab9afd9717286447067e6c3af94d518e1fbf52ec966b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yumeow_timer-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for yumeow_timer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 decba2f7d74be36e20ed514aad88566defc81a9969afa0d7dec9be4565a4b885
MD5 88fb692b61012feb3df0b5a1de4b4375
BLAKE2b-256 8f4cc0910c966a3ff0ff0dcef51032068e39c2df650f7e1de6a9726dc9fb6b97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page