perfbench
About
perfbench measures execution time of code snippets with Timeit and uses Plotly to visualize the results.
Feature
It is possible to select measurement modes.
It is possible to switch between layout sizes dynamically.
It is possible to switch between axes scales dynamically.
It is possible to switch between subplots dynamically.
The result of the benchmark can be saved locally as a html.
The result of the benchmark can be saved locally as a png. Requires installation oforca. When not to use the function, you do not need to install orca separately.
Compatibility
perfbench works with Python 3.5 or higher.
Dependencies
tqdm(4.6.1 or higher.)
cerberus(1.1 or higher.)
plotly(3.0.0 or higher)
notebook(6.0 or higher.)
ipywidgets(7.2 or higher.)
Installation
pip install perfbench
Usage
Plotting a single figure. Here is the demonstration.
import numpy as np
from perfbench import *
bm = Benchmark(
datasets=[
Dataset(
factories=[
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=[
Kernel(
stmt='np.around(DATASET)',
setup='import numpy as np',
label='around'
),
Kernel(
stmt='np.rint(DATASET)',
setup='import numpy as np',
label='rint'
)
],
xlabel='dataset sizes',
title='around vs rint',
)
bm.run()
bm.plot()
plot1
Plotting multiple plots on a single figure. Here is the demonstration.
import numpy as np
from perfbench import *
bm = Benchmark(
datasets=[
Dataset(
factories=[
lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float16),
],
title='float16'
),
Dataset(
factories=[
lambda n: np.random.uniform(low=-1., high=1., size=n).astype(np.float32),
],
title='float32'
),
Dataset(
factories=[
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=[
Kernel(
stmt='np.around(DATASET)',
setup='import numpy as np',
label='around'
),
Kernel(
stmt='np.rint(DATASET)',
setup='import numpy as np',
label='rint'
),
],
xlabel='dataset sizes',
title='around vs rint',
)
bm.run()
bm.plot()
plot2
plot2
Switching between layout sizes.
import numpy as np
from perfbench import *
bm = Benchmark(
datasets=[
Dataset(
factories=[
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=[
Kernel(
stmt='np.around(DATASET)',
setup='import numpy as np',
label='around'
),
Kernel(
stmt='np.rint(DATASET)',
setup='import numpy as np',
label='rint'
)
],
xlabel='dataset sizes',
title='around vs rint',
layout_sizes=[
LayoutSize(width=640, height=480, label='VGA'),
LayoutSize(width=800, height=600, label='SVGA'),
LayoutSize(width=1024, height=768, label='XGA'),
LayoutSize(width=1280, height=960, label='HD 720p'),
]
)
bm.run()
bm.plot()
plot3
Save as a html.
# same as above
bm.save_as_html(filepath='/path/to/file')
Save as a png.
# same as above
bm.save_as_png(filepath='/path/to/file', width=1280, height=960)
Other Here are a few examples.
License
This software is released under the MIT License, see LICENSE.
Metadata
Release files for perfbench 5.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| perfbench-5.0.0.tar.gz | 227.4 kB | Without provenance | Details |
Release files / perfbench-5.0.0.tar.gz
| Download URL | perfbench-5.0.0.tar.gz |
|---|---|
| Size | 227.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e3496824a59d32bb87a81b98da07de13b63cd1d68d9470338a1d815c7c914b7
|
|
BLAKE2b-256 checksum How to use checksums |
395095897d4413c5b5db3b1a9acc75b2c62e900748d29e9893ac06039daa36f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.3
|
Security for perfbench 5.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.