Easy and accurate timer for Python.
Project description
timer.py
timer.py provides convenient functions to measure time in Python.
Installation
pip install timer.py
Usage
from time import sleep
from timer_py import Timer
timer = Timer()
timer.start()
# Or:
# timer = Timer(start=True)
# A one-second process
sleep(1)
# Printing the elapsed time. The timer will continue to run.
timer.elapsed()
# Output:
# [timer.py] 00:00:01.001
timer.pause()
# A one-second process that won't be counted while the timer is paused.
sleep(1)
timer.resume()
# Another one-second process.
sleep(1)
# Overriding the tag for one time only (the original tag will still be remembered).
timer.elapsed('Checkpoint 1')
# Output:
# [Checkpoint 1] 00:00:02.002
timer.set_tag('Custom title')
timer.restart()
# Another one-second process.
sleep(1)
# Storing the elapsed time to a variable as a float while hiding the output.
elapsed = timer.elapsed(print=False)
print(elapsed)
# Output:
# 00:00:01.001
timer.stop()
# Output:
# [Custom title] 00:00:01.001
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timer.py-2.5.0.tar.gz
(15.1 kB
view details)
Built Distribution
timer.py-2.5.0-py3-none-any.whl
(16.0 kB
view details)
File details
Details for the file timer.py-2.5.0.tar.gz
.
File metadata
- Download URL: timer.py-2.5.0.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16c957d2e22f239aea0e7f19989749e987df131a1fa6a1522351a6fa5fc79545 |
|
MD5 | 719e3b00adac2f067944740ac0622e88 |
|
BLAKE2b-256 | 1bc79ad372500161e294791d031139ac1c124ff993190acfec4862449556acf3 |
File details
Details for the file timer.py-2.5.0-py3-none-any.whl
.
File metadata
- Download URL: timer.py-2.5.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d2c6247cdc83914afd2e5d43ebc8493424151d19309ac71b248c9d47ec43bcb |
|
MD5 | 0ea1af00fdbcda1b417ef09b5bcdb485 |
|
BLAKE2b-256 | dc73594d84682e083a6f8c00c1fd7f87e9bf75926cb86472d59c15c649b724c7 |