Pyrofiler
Toolset for granular memory and cpu live profiling
Quick start
Contextmanager that measures time of execution
# examples/simple_profile.py
import pyrofiler
import time
with pyrofiler.timing('Time elapsed'):
time.sleep(1)
$ python simple_profile.py
Time elapsed : 1.001563310623169
Decorators for profiling functions
# examples/simple_profile_cpu.py
import pyrofiler
@pyrofiler.cpu_util(description='Cpu usage')
@pyrofiler.timed('Time elapsed')
def sum_series(x, N):
return sum([x**i/i for i in range(1, N)])
sum_series(.3, 1000_000)
$ python simple_profile_cpu.py
Time elapsed : 0.13478374481201172
Cpu usage : 29.4
Aggregate the results in common context:
# examples/profile_with_context.py
from pyrofiler import Profiler
import time
prof = Profiler()
with prof.timing('Time 1'):
time.sleep(1)
with prof.timing('Time 2'):
time.sleep(1.5)
print('Profiling data recorded:')
print(prof.data)
$ python profile_with_context.py
Time 1 : 1.0011215209960938
Time 2 : 1.5020403861999512
Profiling data recorded:
{'Time 1': 1.0011215209960938, 'Time 2': 1.5020403861999512}
You can use other actions, for example appending results to some list in data. Check the documentation for more use cases
Design
There are following types of objects in pyrofiler:
Measures, which are run as a context manager
Decorators, that are based on measures
Profiler class that uses decorators to aggregate data
Callbacks
The decorators have an optional argument callback, to which you can pass a function that will handle the data. The function will be passed profiling results as a first argument, as well as any other arguments that you provided to original decorator.
Here, a custom spice argument is provided
def print_spicy_time(time, spice):
print(f'Spice {spice} took {time} seconds')
@pyrofiler.timed(spice='spicy', callback=print_spicy_time)
def spicy_sleep():
time.sleep(10)
Similar products
… and lots of others
Problems
Either you have a cli tool that profiles memory and cpu, but no code api for granular data
or you have stuff like decorators and no memory profiling
Having a live dashboard would help also, use https://github.com/libvis for that
Features
TODO
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.0 (2020-03-04)
First release on PyPI.
Metadata
Release files for pyrofiler 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyrofiler-0.1.11.tar.gz | 22.1 kB | Without provenance | Details for pyrofiler-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyrofiler-0.1.11-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pyrofiler-0.1.11-py2.py3-none-any.whl |
Total release size: 32.5 kB
Release files / pyrofiler-0.1.11.tar.gz
| Download URL | pyrofiler-0.1.11.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7134c3e3c4f1b70e460c8c2ee7ef48bf245efb662c72a5d818881b0eb6de468c
|
|
BLAKE2b-256 checksum How to use checksums |
afe8d6704f96bc2d2de34581dc121d4f0e83a3c8772c80c0079938f7416b10dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / pyrofiler-0.1.11-py2.py3-none-any.whl
| Download URL | pyrofiler-0.1.11-py2.py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6204be45d04ac014ddb23c08d7d78a48158fcc7b4aef8b20c68579a2ee19018f
|
|
BLAKE2b-256 checksum How to use checksums |
02dfcdf7eadbcd54a5e8ff98879fd8b6d282d079150608f3d78cbe8b2a9cc40d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for pyrofiler 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.