yet another random library for measuring python performance
Project description
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 =================
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.4.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for timeitpoj-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8866efa03bc911726894b3313dce3deb8fd3a954e13bf17dfa22efc0f86e853 |
|
MD5 | 836e45d1daf900ba8dcd692de3c114a4 |
|
BLAKE2b-256 | 92a14d060d10f19e5df8a3e946df369c73ccf8045497763b93be899f6b934226 |