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-scale=BENCHMARK_SCALE
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
Built Distribution
File details
Details for the file pytest-benchmark-0.12.0.tar.gz
.
File metadata
- Download URL: pytest-benchmark-0.12.0.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cf8d2d4793ef1f78d3a0f68f824d426b9f49cd2d231d1165ef549096a3334f9 |
|
MD5 | bf2a46032ca88d3e1d4ae24bcf783f68 |
|
BLAKE2b-256 | ce6c921c06bda27da41a6cd62d05f7b657b07a3248148d56f97607d3d42268d7 |
File details
Details for the file pytest_benchmark-0.12.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_benchmark-0.12.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0bc056743071d4f6b5cb6b5313886f7cc686665086131a4be72f93e8ab40dd8 |
|
MD5 | c7f5d2fb72a7dd94f9b2a69e79aece84 |
|
BLAKE2b-256 | 869409ec6d2b7383386b68f643475275fe56262508105a40f796a605f14efd6c |