benchmark
benchmark is a Python benchmarking framework, similar to Steve Purcell’s unittest in basic structure. It’s as simple as:
import benchmark
import math
class Benchmark_Sqrt(benchmark.Benchmark):
each = 100 # allows for differing number of runs
def setUp(self):
# Only using setUp in order to subclass later
# Can also specify tearDown, eachSetUp, and eachTearDown
self.size = 25000
def test_pow_operator(self):
for i in xrange(self.size):
z = i**.5
def test_pow_function(self):
for i in xrange(self.size):
z = pow(i, .5)
def test_sqrt_function(self):
for i in xrange(self.size):
z = math.sqrt(i)
class Benchmark_Sqrt2(Benchmark_Sqrt):
# Subclass the previous benchmark to change input using
# self.setUp()
label = "Benchmark Sqrt on a larger range"
# The above label comes from the class name, this oen
# comes from the label attribute
each = 50
def setUp(self):
self.size = 750000
if __name__ == '__main__':
benchmark.main(format="markdown", numberFormat="%.4g")
# could have written benchmark.main(each=50) if the
# first class shouldn't have been run 100 times.
which produces:
Benchmark Report
================
Benchmark Sqrt
--------------
name | rank | runs | mean | sd | timesBaseline
--------------|------|------|----------|-----------|--------------
pow operator | 1 | 100 | 0.004163 | 0.0001469 | 1.0
sqrt function | 2 | 100 | 0.004584 | 0.000379 | 1.10126499627
pow function | 3 | 100 | 0.005496 | 0.0002709 | 1.32031909568
Benchmark Sqrt on a larger range
--------------------------------
name | rank | runs | mean | sd | timesBaseline
--------------|------|------|--------|----------|--------------
pow operator | 1 | 50 | 0.1265 | 0.004772 | 1.0
sqrt function | 2 | 50 | 0.1375 | 0.004729 | 1.08705384
pow function | 3 | 50 | 0.1649 | 0.003935 | 1.30357975885
Each of the above 450 runs were run in random, non-consecutive order by
`benchmark` v0.1.4 (http://jspi.es/benchmark) with Python 2.7.1
Darwin-11.3.0-x86_64 on 2012-04-17 19:43:01.
More examples are available in the example folder or visit http://jspi.es/benchmark for more information.
Metadata
Release files for benchmark 0.1.5
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 | Actions |
|---|---|---|---|---|
| benchmark-0.1.5.tar.gz | 7.1 kB | Without provenance | Details for benchmark-0.1.5.tar.gz |
Release files / benchmark-0.1.5.tar.gz
| Download URL | benchmark-0.1.5.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f87b25665831d2ed8e15e6826fa489e0b3b66db30ec6881d3200b5b32fd7c23
|
|
BLAKE2b-256 checksum How to use checksums |
e9afe0390a38d8d8920a189775102d69fa19107c0b67f75c7934bc166e05d504
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for benchmark 0.1.5
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.