Skip to main content

Benchmarking tools for Python

Project description

Tools to benchmark Python solutions on runtime performance and visualize. Based on timeit, it primarily aims to functionally simulate the timeit behaviour and hence the name! This facilitates benchmarking on multiple datasets and solutions.

Documentation

Docs

Installation

Pull latest development release on GitHub and install in the current directory :

pip install -e git+https://github.com/droyed/benchit.git@master#egg=benchit

Getting started

Consider a setup to compare NumPy ufuncs - sum, prod, max on arrays varying in their sizes. To keep it simple, let’s consider 1D arrays. Thus, we would have :

>>> import numpy as np
>>> funcs = [np.sum,np.prod,np.max]
>>> inputs = [np.random.rand(i) for i in 10**np.arange(5)]

>>> t = benchit.timings(funcs, inputs)
>>> t
Functions       sum      prod      amax
Len
1          0.000004  0.000004  0.000003
10         0.000004  0.000004  0.000004
100        0.000004  0.000004  0.000004
1000       0.000004  0.000007  0.000004
10000      0.000008  0.000022  0.000007

It’s a dataframe-like object and as such we can plot it. It automatically adds in specs into the title area to convey all of available benchmarking info :

>>> t.plot(logy=True, logx=True)

plot1

More realistic example

Let’s consider a setup where functions accept more than one argument. Let’s take the case of computing euclidean distances between two 2D arrays. We will feed in arrays with varying number of rows and 3 columns to represent data in 3D Cartesian coordinate system and benchmark two commonly used functions in Python.

# Setup input functions
>>> from sklearn.metrics.pairwise import pairwise_distances
>>> from scipy.spatial.distance import cdist
>>> fns = [cdist, pairwise_distances]

# Setup input datasets
>>> import numpy as np
>>> in_ = {(n,3):[np.random.rand(n,3), np.random.rand(n,3)] for n in [10,100,500,1000,4000]}

# Get benchmarking object (dataframe-like) and plot results
>>> t = benchit.timings(fns, in_, multivar=True)
>>> t.plot()

plot2

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

benchit-0.0.1.tar.gz (9.5 kB view details)

Uploaded Source

File details

Details for the file benchit-0.0.1.tar.gz.

File metadata

  • Download URL: benchit-0.0.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/2.7.17

File hashes

Hashes for benchit-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ab4dbc56ece2c5f56d8ff90b47e7e942627b86a276410b9ed726a0363552f8de
MD5 79dc2a1ff07e81f5e13a11f1a3207290
BLAKE2b-256 311719b9e4211e2d25040f90cbde5eff1aa6325dd15940f47f3c6e8b19572214

See more details on using hashes here.

Supported by

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