Skip to main content

Performance plots for small Python code snippets

Project description

Build Status Code Health codecov PyPi Version GitHub stars

perfplot extends Python’s very own timeit by testing snippets with input parameters (e.g., the size of an array) and plotting the results.

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

  1. bump the __version__ number,

  2. publish to PyPi and tag on GitHub:

    $ make publish

License

perfplot is published under the MIT license.

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

perfplot-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file perfplot-0.1.0.tar.gz.

File metadata

  • Download URL: perfplot-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for perfplot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f94efb82cbbdc2848014c259de8a5e60196887dff3eaafce549ff446b1492376
MD5 550bbb1338206ea9df1ef1649beefc14
BLAKE2b-256 ef4796fb3b955d0154855b3536dde81206d1d3fc482b6a5b6468e3b8697a50ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page