Lightweight profiler with checkpoints
Project description
sProfiler
Python script profiler/timer supporting code checkpoints and reporting.
Installation
pip install sprofiler
Usage
Use the Timer
to create named checkpoints throughout your code. Checkpoints need a 'start' and a 'stop', and
multiple iterations are combined to summarize how long it takes to complete each leg. The report()
function
prints the results from all checkpoints.
import sprofiler as sp
from time import sleep
pr = sp.Profiler()
pr.start('program')
print('Code outside loop')
sleep(1)
for _ in range(10):
pr.start('loop')
print('Code in loop')
sleep(1)
pr.stop('loop')
pr.stop('program')
pr.report()
The printed report appears as:
program | 11.0 s ± 0.0 s per iteration, n = 1
loop | 1.0 s ± 0.0 s per iteration, n = 10
Future Directions
- Automatic logging, so that
report()
isn't strictly needed - Function decorators
- Potential support for more complex profiling
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
sprofiler-0.0.1.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for sprofiler-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 923d220986ddfd3f296f9feaa32475373caa4338e40680cfd8f9b41919d87c93 |
|
MD5 | e1ecaae1814355950170a8b097c52c4c |
|
BLAKE2b-256 | 6d36f5fc4c7dbf3978c1e042f6217aa2c402d40d78b046b1d295484c00f59423 |