Pytest integration

Install:

pip install "benchcore[pytest]"

Use the typed fixture:

import pytest

from benchcore.core.models import BenchmarkConfig
from benchcore.integrations.pytest import BenchCoreFixture


@pytest.mark.benchcore(
    name="sorted-small",
    config=BenchmarkConfig(rounds=5, iterations=10),
)
def test_sorted(benchcore: BenchCoreFixture) -> None:
    result = benchcore(sorted, [3, 1, 2])
    assert result.value == [1, 2, 3]

The marker is optional. Without it, the pytest node ID identifies the report and default configuration is used.

Options

pytest --benchcore-quiet
pytest --benchcore-save=.benchcore

--benchcore-save writes schema-validated reports atomically. A benchmark exception remains a normal pytest failure and produces no partial report.

Disable plugin autoloading with:

pytest -p no:benchcore