yet another random library for measuring python performance
Project description
Python Timeit
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 =================
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
timeitpoj-0.1.3.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for timeitpoj-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17033dfe45fe838ad3a79461e04ddfce6de3c6756280198f29300c8fb225e502 |
|
MD5 | e9b327ed396ce452e0cc43971a488eb5 |
|
BLAKE2b-256 | eb5a10234c03bfb41a511920fd1c2c6562a7956a23aa382329f6787140d7683a |