Skip to main content

perfbench is a perfomance benchmarking module for Python code.

Project description

License Build Status PyPI version

perfbench

About

perfbench is a perfomance benchmarking module for Python code.

Feature

  • The result of the benchmark can be saved locally as html.

  • The result of the benchmark can be saved locally as png. Requires installation oforca.

Compatibility

perfbench works with Python 3.3 or higher.

Dependencies

  • ipython(6.0.0 or higher.)

  • tqdm(4.6.1 or higher.)

  • plotly(2.7.0 or lower)

Installation

pip install perfbench

Usage

plotting a single figure.

import numpy as np
from perfbench.process import *


bm = Benchmark(
    setups=[
        dict(
            func=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float64),
            title='float64'
        )
    ],
    kernels=[
        dict(
            func=lambda x: np.around(x),
            label='around'
        ),
        dict(
            func=lambda x: np.rint(x),
            label='rint'
        )
    ],
    ntimes=[2 ** n for n in range(26)],
    xlabel='samples',
    title='around vs rint',
    logx=True
)
bm.run()
bm.plot()
plot1

plot1

plotting multiple figures.

import numpy as np
from perfbench.process import *


bm = Benchmark(
    setups=[
        dict(
            func=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float16),
            title='float16'
        ),
        dict(
            func=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float32),
            title='float32'
        ),
        dict(
            func=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float64),
            title='float64'
        )
    ],
    kernels=[
        dict(
            func=lambda x: np.around(x),
            label='around'
        ),
        dict(
            func=lambda x: np.rint(x),
            label='rint'
        )
    ],
    ntimes=[2 ** n for n in range(26)],
    xlabel='samples',
    title='around vs rint',
    logx=True
)
bm.run()
bm.plot()
plot2

plot2

save as html.

# same as above
bm.save_as_html(filepath='/path/to/file')

save as png.

# same as above
bm.save_as_png(filepath='/path/to/file')

License

This software is released under the MIT License, see 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

perfbench-0.4.0.tar.gz (154.2 kB view hashes)

Uploaded Source

Built Distribution

perfbench-0.4.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

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