Skip to main content

Timing class for measuring elapsed time and average elapsed time.

Project description

noiftimer

Simple timer class to track elapsed time.
Install with:

pip install noiftimer

Usage:

>>> from noiftimer import Timer, time_it
>>> import time

Timer object

>>> def very_complicated_function():
...     time.sleep(1)
...
>>> timer = Timer()
>>> for _ in range(10):
...     timer.start()
...     very_complicated_function()
...     timer.stop()
...
>>> print(timer.stats)
elapsed time: 1s 1ms 173us
average elapsed time: 1s 912us
>>> timer.elapsed
1.001173496246338
>>> timer.elapsed_str
'1s 1ms 173us'
>>> timer.average_elapsed
1.0009121656417848
>>> timer.average_elapsed_str
'1s 912us'

time_it decorator (executes the decorated function 10 times)

>>> @time_it(10)
... def very_complicated_function():
...     time.sleep(1)
...
>>> very_complicated_function()
very_complicated_function average execution time: 1s 469us

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

noiftimer-2.4.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

noiftimer-2.4.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file noiftimer-2.4.3.tar.gz.

File metadata

  • Download URL: noiftimer-2.4.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for noiftimer-2.4.3.tar.gz
Algorithm Hash digest
SHA256 3495c6928e982949e01acacbf651a4fa251eb1975ce3c9df7a51abbfe0644594
MD5 734b283a54f0631bf812abec1f4e7aa1
BLAKE2b-256 03a356c34080416a2e538841c4eb14be562185a60b2143dfec8de159c7c950af

See more details on using hashes here.

File details

Details for the file noiftimer-2.4.3-py3-none-any.whl.

File metadata

  • Download URL: noiftimer-2.4.3-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for noiftimer-2.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d2d55c2caf692dcbcf3f8336ad0c29bf7e37fe43e54a72a6ea42f8fe40274c91
MD5 bd6689a1a1be891f608f772bac4536f7
BLAKE2b-256 29e281458053760454d78922a682d382a0990279bef67576937d3818dc9468db

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