Timeitpoj
yet another random library for measuring python performance
Usage in production
if you do not need to measure performance of your code in a production environment, simply set the environment
variable TIME_IT tofalse
Example
from timeitpoj.timeit import TimeIt
from time import sleep
BASE_TIME = 0.1
with TimeIt("my timer") as timer:
print("Executing my timer....")
sleep(BASE_TIME)
with timer("my subtimer"):
print("Executing my subtimer....")
sleep(BASE_TIME)
with timer("my nested subtimer"):
print("Executing my nested subtimer....")
sleep(BASE_TIME)
for _ in range(2):
with timer("my super nested subtimer 2"):
sleep(BASE_TIME)
for _ in range(5):
with timer("my nested subtimer 2"):
sleep(BASE_TIME)
with timer("my subtimer 992"):
print("Executing my subtimer 2....")
sleep(BASE_TIME)
with timer("my subtimer 4"):
print("Executing my subtimer 4....")
sleep(BASE_TIME)
# Something that is not covered by the timer
sleep(BASE_TIME * 2)
Output
================= [my timer] TIMEIT REPORT =================
[TIMEIT] my timer took 1.403 seconds
└── [81.80%] my subtimer ; 0.902 seconds
├── [37.49%] my nested subtimer ; 0.300 seconds
└── my super nested subtimer 2 ; 0.200 seconds ; 2 times ; avg 0.100 seconds
└── [62.51%] my nested subtimer 2 ; 0.501 seconds ; 5 times ; avg 0.100 seconds
├── [ 9.12%] my subtimer 992 ; 0.101 seconds
└── [ 9.08%] my subtimer 4 ; 0.100 seconds
└── [ 0.01%] internal time: 0.112 milliseconds
[78.56%% COVERAGE] time accounted for: 1.102 seconds, time unaccounted for: 0.301 seconds
[TIMEIT] report generation took 0.190 milliseconds
================= [my timer] TIMEIT REPORT =================
Metadata
Release files for timeitpoj 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| timeitpoj-0.1.11.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| timeitpoj-0.1.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.7 kB
Release files / timeitpoj-0.1.11.tar.gz
| Download URL | timeitpoj-0.1.11.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a5f27b923e98d90f0e9816c1cead3c052e1aa51c4f0ce86fe5be8de264ad371
|
|
BLAKE2b-256 checksum How to use checksums |
e6f58ee1fce1bade0bcf13d1350f6a35094bfd8b2fda630552f393ac2f46c85f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Linux/6.1.70-1-lts
|
Release files / timeitpoj-0.1.11-py3-none-any.whl
| Download URL | timeitpoj-0.1.11-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d5e719b6f94ba2fb8061dc4d442780611dc806224eb774ac21d571e09527bfb
|
|
BLAKE2b-256 checksum How to use checksums |
0cdcf75ce8782c27f154b45f8d0f10f4348ae5628041a0340c6088298c96cd86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Linux/6.1.70-1-lts
|