A convenient wrapper library for different Python profilers.
Project description
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_bycan be used to sort the results according to the supplied criteria. All criterias can be found here.out_linescontrols the number of lines in results. UseNoneor 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.
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
File details
Details for the file PyProfilers-0.1.3.tar.gz.
File metadata
- Download URL: PyProfilers-0.1.3.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ea72ed290bbab85b49e213650ce2870b13e5981e52cc3ee3a06f09cf3773555
|
|
| MD5 |
62ebc9aba5ac755e4fec2dc061ad3fb0
|
|
| BLAKE2b-256 |
e1ae9a4bd94d73f1f4e9ae78f3b38006c73f86cca40bdd354a7f83b463a24df5
|