Estimate Asymptotic Runtime Complexity from Bytecode executions
Project description
Python Performance Analysis Library or py-pal is a bytecode profiling toolkit.
Installation
This project requires CPython to run. Install Python >= 3.7, then install py-pal by running:
pip install py-pal
Documentation
TBA
Overview
Calling py-pal as module with
python -m py_pal file.py
or
pypal file.py
Measure specific functions using the decorator:
from py_pal.core import profile
@profile
def test():
pass
Using the context manager:
from py_pal.tracer import Tracer
with Tracer() as t:
pass
estimator = ComplexityEstimator(t)
res = estimator.export()
# Do something with the resulting DataFrame
print(res)
Using the API:
from py_pal.estimator import ComplexityEstimator
from py_pal.tracer import Tracer
t = Tracer()
t.trace()
# Your function
pass
t.stop()
estimator = ComplexityEstimator(t)
res = estimator.export()
# Do something with the resulting DataFrame
print(res)
Modes
Profiling and Performance Testing
Restrictions
The Tracing process does not work for multi-threaded code.
Tracing processes
Development
To run the all tests run:
pip install -r dev-requirements.txt
pytest tests tests_cython
FAQ
Why not use a standard profiler?
Using absolute timing data vs synthetic timing data using opcodes.
What’s New in Py-PAL 0.1.6
More accurate Data Collection
The Tracer is enhanced by measuring builtin function calls with AdvancedOpcodeMetric.
Opcodes resembling a function call .e.g FUNCTION_CALL are filtered for built in function calls. If the called function is found in the complexity mapping a synthetic Opcode weight gets assigned. A builtin function call is evaluated using its argument and a pre-defined runtime complexity e.g. O(n log n) for sort().
The feature is enabled by default
The calculation produces a performance overhead and can be disabled by providing a OpcodeMetric instance to the Tracer
The AdvancedOpcodeMetric instance assigned to the Tracer provides statistics about how many builtin function calls were observed and how many were found in the complexity map
Bugfixes
Cleaning data after normalization introduced wrong data points
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
Built Distributions
Hashes for py_pal-0.1.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6de852797c363bba2daaf0996b6d92a9425396671848e7928a7c174574223c43 |
|
MD5 | 15901d268eb80bb0aef456234d54173e |
|
BLAKE2b-256 | 8eff0b27f22b044e39eec3cde028649a9a89d7053a3b2d3bd1134d3de09d7d32 |
Hashes for py_pal-0.1.7-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67b8f0c744b558905d8304acf70d033c555ad757a08018541127cb62157c54b0 |
|
MD5 | 451cc19eb7e85bc9dfcc27087bb79439 |
|
BLAKE2b-256 | 196a55794b97aa24ad2b80a8a83a9cf71b6a780d84b0818aa65d6f00a308efd6 |
Hashes for py_pal-0.1.7-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0221210b9e9031e1b623b14f6666cf14b39a619e661745772bb1ca0d09080f1 |
|
MD5 | dcb41ae9936f63f98dc76ff4f710e3c2 |
|
BLAKE2b-256 | 57279a8c4496a92913c970e938be35b7020f6ddadad4406527a45a3f4d7c75d9 |
Hashes for py_pal-0.1.7-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d9dc95d513ca015a55a5346f77441f017a07d77766475c43342d654c6864d51 |
|
MD5 | 8dcfa54046a1758751701c93b932b538 |
|
BLAKE2b-256 | 7fcb93e4ffdb662553a1b532b87fe19a431e3931c3435ae07f4966deaab58d5c |
Hashes for py_pal-0.1.7-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4216a096c4e2dd247b41994e5604bcdd708d5a33f7a1dfe476e9f4243d7ea035 |
|
MD5 | 1228cd3fd837b54d79791821eb0d92f7 |
|
BLAKE2b-256 | 41e1e3b22b9302fefdb70b9034dd36e68e9e80e67930796c9806a236d32680b1 |
Hashes for py_pal-0.1.7-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a05d89aae9dfdb068e50052b1012d9f7435a804b83e2479297137ba2fa050080 |
|
MD5 | 7d6c71c59d51c5b2ef268d60bc4355b6 |
|
BLAKE2b-256 | a3af9af256c7a0d438b141dd66904da4f77b7e7042c6587735874d9cae851c09 |
Hashes for py_pal-0.1.7-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1032dd1401f426c17c286ec7f55729f9259492004599c96aec95814d433309bc |
|
MD5 | 85789a48de99121442c623f92d67b60d |
|
BLAKE2b-256 | f03f5ceed25f64ff8caa39ff27b20a0e876fa59143bfc2eef71b896f2b2845b0 |
Hashes for py_pal-0.1.7-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 425dc2692f61ed90765f58b1e9b44eea4c9bbc1fc11137b510a151785b1927a1 |
|
MD5 | a7bef3130b93f130889b7b8cb25fa3bc |
|
BLAKE2b-256 | 9301ccfbb0c2f4546782ece361259def17ac00419440705119539b5a796b3f75 |