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.8.0.tar.gz
(27.3 kB
view details)
Built Distribution
File details
Details for the file pytest-benchmark-0.8.0.tar.gz
.
File metadata
- Download URL: pytest-benchmark-0.8.0.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c729e86ab17c7b269534a7db38308c3663ef4451affe75a35c19bad3c3ee3649 |
|
MD5 | 0a7ea865916b355583d3d33a40ddeae1 |
|
BLAKE2b-256 | 1d0019ab698ea7befbac985df1046c98d639fa8ecb89c0de905bb0376a21ea55 |
File details
Details for the file pytest_benchmark-0.8.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_benchmark-0.8.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f625dbd0c126d4450473c65ea94c5159a26138605fc96186bb9cbb887b8e79a |
|
MD5 | 02bf043e04234343c76dbfd50bfc904a |
|
BLAKE2b-256 | 57c498420216d3a419c4fab09f0fec897de154f80713f719150efc9560405f1e |