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
Installation
pip install perfbench
Usage
plotting a single figure.
Here is the
demonstration.
import numpy as np
from perfbench.process import *
bm = Benchmark(
datasets=[
dict(
stmt=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float64),
title='float64'
)
],
dataset_sizes=[2 ** n for n in range(26)],
kernels=[
dict(
stmt=lambda x: np.around(x),
label='around'
),
dict(
stmt=lambda x: np.rint(x),
label='rint'
)
],
xlabel='dataset sizes',
title='around vs rint',
)
bm.run()
bm.plot()
plotting multiple figures.
Here is the
demonstration.
import numpy as np
from perfbench.process import *
bm = Benchmark(
datasets=[
dict(
stmt=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float16),
title='float16'
),
dict(
stmt=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float32),
title='float32'
),
dict(
stmt=lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float64),
title='float64'
)
],
dataset_sizes=[2 ** n for n in range(26)],
kernels=[
dict(
stmt=lambda x: np.around(x),
label='around'
),
dict(
stmt=lambda x: np.rint(x),
label='rint'
)
],
xlabel='dataset sizes',
title='around vs rint',
)
bm.run()
bm.plot()
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', width=1280, height=960)
License
This software is released under the MIT License, see 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
perfbench-0.6.1.tar.gz
(224.9 kB
view hashes)
Built Distribution
Close
Hashes for perfbench-0.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8f53747435057816fcf4c4875ce447530e4b508c8798a690c2bc374666fc429 |
|
MD5 | d993c180da7d54693c27fcf7f82a018c |
|
BLAKE2b-256 | 2c88d91f9ca214d40c804d5effaf91f46180e3e4dcbb19fa5d21a93ee605bc0f |