Measuring time to run functions, methods or blocks of code made easy.
Project description
Pytimers is a python micro library that allows you to quickly measure time to run functions, methods or individual blocks of codes. Here’s a quick demo.
import logging
from time import sleep
from pytimers import timer
logging.basicConfig(level=logging.INFO)
@timer
def foo() -> None:
print("Some heavy lifting.")
sleep(2)
if __name__ == "__main__":
print("Let's call the function decorated with timer.")
foo()
print("Use timer context manager.")
with timer.label("sleeping block"):
print("Some more work to do.")
sleep(1)
Let's call the function decorated with timer.
Some heavy lifting.
INFO:pytimers.triggers.logger_trigger:Finished foo in 2s 0.494ms [2.0s].
Use timer context manager.
Some more work to do.
INFO:pytimers.triggers.logger_trigger:Finished sleeping block in 1s 1.247ms [1.001s].
See the full Documentation.
Build Status
PyPi
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
pytimers-3.1.tar.gz
(7.5 kB
view details)
Built Distribution
File details
Details for the file pytimers-3.1.tar.gz
.
File metadata
- Download URL: pytimers-3.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df68c672a2fdd13e59fd767dddc0eafa90de6585eadfc0132d6ea865dc46baa8 |
|
MD5 | 0c11c97e59c90a001ed13064fdc1ef93 |
|
BLAKE2b-256 | 4619d8e3f1dcbe12cc14502d947e0c1d9e0caed8ac9e781bafcb469ab0a940df |
File details
Details for the file pytimers-3.1-py3-none-any.whl
.
File metadata
- Download URL: pytimers-3.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c83820058cb2052faf4a53892306daeecd7aec49350e72e2c3dfdac4b30dfeb |
|
MD5 | 356b6fe6d18ebf7ecc14baeafca66f60 |
|
BLAKE2b-256 | 5829d90cfc16d60609ccea837d73f9f1bfc0ad3b2b332d287a0f1767c493b98f |