Skip to main content

Performance plots for Python code snippets

Project description

perfplot

CircleCI codecov Codacy grade PyPi Version GitHub stars

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.

Benchmarking and plotting can be separated, too. This allows multiple plots of the same data, for example:

out = perfplot.bench(
    # same arguments as above
    )
out.show()
out.save('perf.png')

Other examples:

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

  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.3.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

perfplot-0.3.2-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for perfplot-0.3.2.tar.gz
Algorithm Hash digest
SHA256 9ad2d43a0eb76173a0d2816eb71637d94256241d38ca8bacef7de6c87b775d13
MD5 7a883ad7584a81c5d947d2e5172e0418
BLAKE2b-256 c6cf8c422c173b17910bc0016315ada0865eaf195fcf053cb9f0d6f98bf78ad2

See more details on using hashes here.

File details

Details for the file perfplot-0.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for perfplot-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1183652f6ff3be9b8fd3c5c85834f2ab4ee30ef408d53aaa438f504d8cd8e6b1
MD5 6e0edec4fee4040ceb7b7336c8d5f0a1
BLAKE2b-256 827679fdb6615364b40fdef840a0273f28e33e569ec0d9eeb68aa980d0012a8a

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