Skip to main content

py.test fixture for benchmarking code

Project description

Documentation Status Travis-CI Build Status AppVeyor Build Status Coverage Status Code Quality Status Scrtinizer Status
PyPI Package latest release PyPI Package monthly downloads PyPI Wheel Supported versions Supported imlementations

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

https://pytest-benchmark.readthedocs.org/

Obligatory screenshot

Screenshot of py.test summary

Development

To run the all tests run:

tox

Changelog

0.1.0 (2014-10-10)

  • First release on PyPI.

Project details


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.9.0.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

pytest_benchmark-0.9.0-py2.py3-none-any.whl (8.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-benchmark-0.9.0.tar.gz.

File metadata

File hashes

Hashes for pytest-benchmark-0.9.0.tar.gz
Algorithm Hash digest
SHA256 3011362df44fa8403ff70408b828accbca556181d84647bda716c938d9cd904d
MD5 d66446924c21be8e9224f27a1d319b5c
BLAKE2b-256 93dc615f6aab4961cc99d0482f3d988099f7c54b48a4627fad59b9ee335ae913

See more details on using hashes here.

Provenance

File details

Details for the file pytest_benchmark-0.9.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_benchmark-0.9.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e64ac48b97c5c12682af6d20362c6c4853e4a124e0ef10ad04d5a528919c5f76
MD5 14b0ce19cab674165f09978237b158e8
BLAKE2b-256 b24e2f249e33ac6a4833f60bdd1979973e579aef76be4d5a81c847a9808d06f7

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page