File: conftest.py

package info (click to toggle)
python-msgspec 0.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,416 kB
  • sloc: javascript: 23,944; ansic: 20,940; python: 19,752; makefile: 26; sh: 23
file content (42 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import pytest

from benchmarks.generate_data import make_filesystem_data


@pytest.fixture
def bench(benchmark, bench_config):
    if not bench_config["calibrate"]:
        return lambda target, *args, **kwargs: benchmark(target, *args, **kwargs)

    return lambda target, *args, **kwargs: benchmark.pedantic(
        target,
        args=args,
        kwargs=kwargs,
        rounds=bench_config["rounds"],
        iterations=bench_config["iterations"],
        warmup_rounds=bench_config["warmup_rounds"],
    )


@pytest.fixture
def filesystem_data(bench_config):
    return lambda size=bench_config["size"]: make_filesystem_data(size)


@pytest.fixture(scope="class")
def shared_data():
    """
    This is used to share data between serially-executed tests within a class.
    """
    return {}


@pytest.fixture
def bench_config(request):
    return {
        "calibrate": request.config.getoption("--calibrate"),
        "rounds": request.config.getoption("--rounds"),
        "warmup_rounds": request.config.getoption("--warmup-rounds"),
        "iterations": request.config.getoption("--iterations"),
        "size": request.config.getoption("--size"),
    }