A very simple profiler for Python.
Project description
Nothing to see here...
...just a very simple python profiler
Examples
With context manager
Code
# Use default profiler
from sipro import default_profiler as profiler
# Create your own profiler
from sipro import Profiler
my_profiler = Profiler()
with profiler('my loop'):
for i in range(1000):
pass
with profiler('nested parent'):
for i in range(50):
pass
with profiler('nested child 1'):
for i in range(50):
pass
with profiler('nested child 2'):
for i in range(50):
pass
print(profiler)
Output
100.0% (100.0%)
my loop: 37.4% (37.4%)
nested parent: 17.6% (17.6%)
nested child 1: 14.5% (2.5%)
nested child 2: 11.3% (2.0%)
...: 74.2% (13.0%)
...: 45.0% (45.0%)
With functions
Code
from sipro import default_profiler as profiler
@profiler.wrap
def inherit_name():
for i in range(1000):
pass
from functools import partial
@partial(profiler.wrap, name='custom_name')
def dont_use_fn_name():
for i in range(1000):
pass
# Functions also nest properly
inherit_name()
dont_use_fn_name()
print(profiler)
Output
100.0% (100.0%)
custom_name: 71.4% (71.4%)
inherit_name: 42.2% (30.1%)
...: 57.8% (41.3%)
...: 28.6% (28.6%)
Output
There are two ways of getting the output:
- Cast to string
str(profiler)- Output same as above - Get
dict, byprofiler.dict()- Structure:{ 'sum': <time in seconds, float>, 'children': { '<child_name>': { ...child values } } }
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
sipro-1.0.1.tar.gz
(4.0 kB
view details)
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
sipro-1.0.1-py3-none-any.whl
(4.2 kB
view details)
File details
Details for the file sipro-1.0.1.tar.gz.
File metadata
- Download URL: sipro-1.0.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90bd6afaa2b83f8a48bb4a17f172fc6000217eaed5f6ffb3f871f7473d886893
|
|
| MD5 |
e8d257342c3aaccf5fa496fc922190d4
|
|
| BLAKE2b-256 |
2e4a31097088a487aba65f3e07ff19866d848fcfa1a237c41765855adb7a4e02
|
File details
Details for the file sipro-1.0.1-py3-none-any.whl.
File metadata
- Download URL: sipro-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4f15c5b9dca2fe53d788d2560271182b9f3aa66e951f18f984734daadc89597
|
|
| MD5 |
1d14507ca4f7312b15f54a6816705942
|
|
| BLAKE2b-256 |
d73de60935ac7e176fbae51987b45f65da5f40adfb8d7f0d6c1f7e6212d6419f
|