Accurate speed profiler for Python code using perf_counter.
Project description
speed-profiler
Accurate speed profiler for Python code using perf_counter.
This module is for finding bottlenecks in Python code. The first call to the module
initializes it with a name to identify the profile. Following that are calls to mark()
for timing purposes. Here's an example (Also in the demo folder):
Installation
pip install speed-profiler
Usage
from speed_profiler import SpeedProfiler
from time import sleep
from pprint import pprint
sp = SpeedProfiler('Sleep Tester')
def foo():
sleep(0.2)
sp.mark('Foo')
def bar():
sleep(0.1)
sp.mark('bar')
def baz():
foo()
bar()
sp.mark('baz')
profile = sp.stop()
pprint(profile)
baz()
Output:
[{'duration': 0.20027251401916146,
'identifier': 'Sleep Tester',
'line_num': 5,
'percent_time': 66.66},
{'duration': 0.10016519500641152,
'identifier': 'Foo',
'line_num': 10,
'percent_time': 33.34},
{'duration': 1.0420975740998983e-05,
'identifier': 'bar',
'line_num': 15,
'percent_time': 0.0},
{'duration': 9.390001650899649e-06,
'identifier': 'baz',
'line_num': 21,
'percent_time': 0.0}]
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file speed-profiler-0.0.4.tar.gz.
File metadata
- Download URL: speed-profiler-0.0.4.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf61c833364ef9d6539785a94a6a93d094af518318fad7685883129e6d963e7c
|
|
| MD5 |
210cdacda8a0ba7aa6095450abdde25c
|
|
| BLAKE2b-256 |
4800bffdc3f17ad525e484752b469c6f7a3f6a8e8bcfe23648877a970225de6c
|
File details
Details for the file speed_profiler-0.0.4-py3-none-any.whl.
File metadata
- Download URL: speed_profiler-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02f99adf688fd1adb7597fbb9e55e90bb41235f5d2e18fce17338a9f93dd691f
|
|
| MD5 |
151a893291ab9d1b9c0c772ffdd96925
|
|
| BLAKE2b-256 |
deade8c10e3c1447c3ca65b4134b5c138a7fde4887048c288ef7345192bb9389
|