Performance plots for small Python code snippets
Project description
perfplot extends Python’s very own timeit by testing snippets with input parameters (e.g., the size of an array) and plotting the results. (By default, perfplot asserts the equality of the output of all snippets, too.)
For example, to compare different NumPy array concatenation methods, the script
import numpy
import perfplot
perfplot.show(
setup=lambda n: numpy.random.rand(n),
kernels=[
lambda a: numpy.c_[a, a],
lambda a: numpy.stack([a, a]).T,
lambda a: numpy.vstack([a, a]).T,
lambda a: numpy.column_stack([a, a]),
lambda a: numpy.concatenate([a[:, None], a[:, None]], axis=1)
],
labels=['c_', 'stack', 'vstack', 'column_stack', 'concat'],
n_range=[2**k for k in range(15)],
xlabel='len(a)'
)
produces
Clearly, stack and vstack are the best options for large arrays!
Installation
Python Package Index
perfplot is available from the Python Package Index, so simply type
pip install -U perfplot
to install or upgrade.
Manual installation
Download perfplot from GitHub and install it with
python setup.py install
Testing
To run the perfplot unit tests, check out this repository and type
pytest
Distribution
To create a new release
bump the __version__ number,
publish to PyPi and tag on GitHub:
$ make publish
License
perfplot is published under the MIT license.
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 Distributions
Built Distribution
Hashes for perfplot-0.2.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459b7c90d08dc733f4a532a6a8432faddf0f92260f5e19f7811ddb0c9a9dd09b |
|
MD5 | b02ddfb6eb79f66879a991e18a939631 |
|
BLAKE2b-256 | 43bba356ffc0fe13c9535b3e0f1c4f71ced6790895b6cc2dc0f9feaa0097197f |