py.test fixture for benchmarking code
Project description
A py.test fixture for benchmarking code.
Free software: BSD license
Installation
pip install pytest-benchmark
Usage
def test_my_stuff(benchmark): with benchmark: # Code to be measured result = time.sleep(0.000001) # Extra code, to verify that the run completed correctly. # Note: this code is not measured. assert result is None
py.test command-line options:
- --benchmark-max-time=BENCHMARK_MAX_TIME
Maximum time to spend in a benchmark (including overhead).
- --benchmark-max-iterations=BENCHMARK_MAX_ITERATIONS
Maximum iterations to do.
- --benchmark-min-iterations=BENCHMARK_MIN_ITERATIONS
Minium iterations, even if total time would exceed max-time.
- --benchmark-timer=BENCHMARK_TIMER
Timer to use when measuring time.
- --benchmark-disable-gc
Disable GC during benchmarks.
- --benchmark-skip
Skip running any benchmarks.
- --benchmark-only
Only run benchmarks.
Setting per-test options:
@pytest.mark.benchmark(group="group-name", max_time=0.5, max_iterations=5000, min_iterations=5, timer=time.time, disable_gc=True) def test_my_stuff(benchmark): with benchmark: # Code to be measured result = time.sleep(0.000001) # Extra code, to verify that the run completed correctly. # Note: this code is not measured. assert result is None
Documentation
Obligatory screenshot
Development
To run the all tests run:
tox
Changelog
0.1.0 (2014-10-10)
First release on PyPI.
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
pytest-benchmark-0.7.0.tar.gz
(26.0 kB
view details)
Built Distribution
File details
Details for the file pytest-benchmark-0.7.0.tar.gz
.
File metadata
- Download URL: pytest-benchmark-0.7.0.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3823e5fce29d9554d8378737cc0deacd45b1b762d2e13be4217b08068220224 |
|
MD5 | f0bd7a4aa107f6fad96f287a1dbc09bf |
|
BLAKE2b-256 | fbd397ddca910ce9e4e105c467474952234a17545b8d3713f33a5abca97148b3 |
Provenance
File details
Details for the file pytest_benchmark-0.7.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_benchmark-0.7.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 056197050cf78ddd1e8c8b68cfa5297347523cbfeb9d09b94edcd938665e76f3 |
|
MD5 | c4d3311c631d269d9000bb7b06578d26 |
|
BLAKE2b-256 | 132c8e30ff39fda85112fa975a536e5c750c79d3ea71a947b5f53b420a7c32e4 |