Performance plots for Python code snippets
Project description
perfplot
perfplot extends Python's 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=numpy.random.rand,
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.
Other examples:
- Making a flat list out of list of lists in Python
- Most efficient way to map function over numpy array
- numpy: most efficient frequency counts for unique values in an array
- Most efficient way to reverse a numpy array
- How to add an extra column to an numpy array
- Initializing numpy matrix to something other than zero or one
Installation
perfplot is available from the Python Package Index, so simply do
pip install -U perfplot
to install or upgrade.
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 Distribution
Built Distribution
Hashes for perfplot-0.2.9-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce519327e5608250b81b540314299d1d325d886bda03364e1d50fb3f133ffb3e |
|
MD5 | 7bc66d63ae0e381088f370a448542632 |
|
BLAKE2b-256 | 2339bf6fd1eef9a0693820dff14102ec2aad459d63154dddfd3fdb8e25a99ab2 |