Skip to main content

PyProfilers

PyProfilers is collection of wrapper functions for various Python profilers which aims to make profiling more convenient.

Installing

Install and update using pip:

pip install -U pyprofilers

Simple examples

Import PyProfilers

import pyprofilers as pp

Profile with cProfile

Use the standard Python cProfile to list the cumulative time spent in the function func and all its subfunctions:

@pp.profile(sort_by='cumulative', out_lines=30)
def func():
  ...
  • sort_by can be used to sort the results according to the supplied criteria. All criterias can be found here.
  • out_lines controls the number of lines in results. Use None or ommit the arugment to show all.

Profile with line_profiler

Use the line_profiler to list time spent within each line of func:

@pp.profile_by_line(exit=1)
def func():
  ...

Set exit to True to stop the execution after the first call to func returns. This is useful if func is called multiple times to avoid the repeated output of the profiler statistics.

Simple Timer

To just time the execution of a function use the simple_timer decoration:

@pp.simple_timer(num=1)
def func():
  ...

The num argument can be used to specify how often the function should be executed.

Release files for PyProfilers 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyProfilers 0.1.3
File Size Uploaded
PyProfilers-0.1.3.tar.gz 15.6 kB Details

Release files / PyProfilers-0.1.3.tar.gz

Download URL PyProfilers-0.1.3.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0ea72ed290bbab85b49e213650ce2870b13e5981e52cc3ee3a06f09cf3773555
BLAKE2b-256 checksum
How to use checksums
e1ae9a4bd94d73f1f4e9ae78f3b38006c73f86cca40bdd354a7f83b463a24df5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page