Skip to main content

Toolset for granular and live profiling

Project description

Pyrofiler Documentation Status

Toolset for granular memory and cpu live profiling

Quick start

Contextmanager that measures time of execution

# examples/
import pyrofiler
import time

with pyrofiler.timing('Time elapsed'):
$ python
Time elapsed : 1.001563310623169

Decorators for profiling functions

# examples/
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
Time elapsed : 0.13478374481201172
Cpu usage : 29.4

Aggregate the results in common context:

# examples/
from pyrofiler import Profiler
import time

prof = Profiler()

with prof.timing('Time 1'):

with prof.timing('Time 2'):

print('Profiling data recorded:')
$ python
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


There are following types of objects in pyrofiler:

  1. Measures, which are run as a context manager

  2. Decorators, that are based on measures

  3. Profiler class that uses decorators to aggregate data


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():

Similar products


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 for that


  • TODO


This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.


0.1.0 (2020-03-04)

  • First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrofiler-0.1.11.tar.gz (22.1 kB view hashes)

Uploaded source

Built Distribution

pyrofiler-0.1.11-py2.py3-none-any.whl (10.4 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page