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.1.0.tar.gz (6.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.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yumeow_timer-0.1.0.tar.gz
  • Upload date:
  • Size: 6.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.1.0.tar.gz
Algorithm Hash digest
SHA256 0da5ec995d7ad112dc12dfb47dcddcbf5c0a379628532d4445449875192f74f2
MD5 176bd777e7019f0603e13c57d513bd60
BLAKE2b-256 3652864c6bbcf05b8df42fbf6a2b9f59103ca53b794606cfbf9473e320f49016

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yumeow_timer-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed37e85e5dd68a2c7adb05e0f39dcf81c0a395d45de02f18c150ef8ef403abe9
MD5 761ba995426d2502ad6bd27e6983083f
BLAKE2b-256 c30f6d2a8824af7e5c598a9c3d25fc3068f7309ef7db35bbbd1b6e7230761a33

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