Python code benchmark library
Project description
Python benchmark library
Installation
pip install penchmark
pip install penchmark[charts]
Example
from penchmark import benchmark_and_print, Callee, InData
callees = (
Callee(callee_name='mul', callee=lambda x: x[0] * x[1]),
Callee(callee_name='nop', callee=lambda x: x)
)
dataset = (
InData(name='small-data', data=(2, 1), count_of_call=100000),
InData(name='big-data', data=(200, 10), count_of_call=1000),
InData(name='skipped-data', data=(1, 1), count_of_call=0)
)
benchmark_and_print(callees, dataset)
or
from penchmark import benchmark_and_print
callees = (
('mul', lambda x: x[0] * x[1]),
('nop', lambda x: x)
)
dataset = (
('small-data', (2, 1), 100000),
('big-data', (200, 10), 1000),
('skipped-data', (1, 1), 0)
)
benchmark_and_print(callees, dataset)
or
from penchmark import benchmark_and_print
def mul(x): return x[0] * x[1]
def nop(x): return x
dataset = (
('small-data', (2, 1), 100000),
('big-data', (200, 10), 1000),
('skipped-data', (1, 1), 0)
)
benchmark_and_print((mul, nop), dataset)
Markdown result
small-data
callee_name | elapsed | ratio |
---|---|---|
nop | 0.0050 | 1.0000 |
mul | 0.0080 | 1.5842 |
big-data
callee_name | elapsed | ratio |
---|---|---|
nop | 0.0000 | 1.0000 |
mul | 0.0001 | 1.7201 |
Summary
callee_name | mean | median |
---|---|---|
nop | 1.0000 | 1.0000 |
mul | 1.6521 | 1.6521 |
or
...
benchmark_and_print((mul, nop), dataset, markdown=False)
Result
SMALL-DATA
callee_name elapsed ratio
------------- --------- -------
nop 0.0050 1.0000
mul 0.0079 1.5944
BIG-DATA
callee_name elapsed ratio
------------- --------- -------
nop 0.0001 1.0000
mul 0.0001 1.7565
SUMMARY
callee_name mean median
------------- ------ --------
nop 1.0000 1.0000
mul 1.6754 1.6754
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
penchmark-0.0.1.tar.gz
(7.7 kB
view hashes)
Built Distribution
Close
Hashes for penchmark-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f20b1e7a7e945e638751672bcd8c6c3952c8aad4eae90ffc7b509a717719aae |
|
MD5 | 90a785a8e46f8e18da81928379df7a58 |
|
BLAKE2b-256 | 412f7f0f9411db3000159a36c0d88260785c14e27a02a440ed9b632d39794ec4 |