pytest-codspeed 3.0.0b0__tar.gz → 3.0.0b2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/PKG-INFO +3 -1
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/pyproject.toml +2 -1
- pytest_codspeed-3.0.0b2/src/pytest_codspeed/__init__.py +7 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/valgrind/__init__.py +2 -2
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/walltime.py +12 -4
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/plugin.py +18 -3
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/utils.py +2 -2
- pytest_codspeed-3.0.0b0/src/pytest_codspeed/__init__.py +0 -5
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/.gitignore +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/LICENSE +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/README.md +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/__init__.py +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/valgrind/_wrapper/.gitignore +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.h +0 -0
- {pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.pyi +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pytest-codspeed
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.0b2
|
|
4
4
|
Summary: Pytest plugin to create CodSpeed benchmarks
|
|
5
5
|
Project-URL: Homepage, https://codspeed.io/
|
|
6
6
|
Project-URL: Documentation, https://docs.codspeed.io/
|
|
@@ -52,6 +52,8 @@ Requires-Dist: importlib-metadata>=8.5.0; python_version < '3.10'
|
|
|
52
52
|
Requires-Dist: pytest>=3.8
|
|
53
53
|
Requires-Dist: rich>=13.8.1
|
|
54
54
|
Requires-Dist: setuptools; python_full_version >= '3.12.0'
|
|
55
|
+
Provides-Extra: build
|
|
56
|
+
Requires-Dist: semver>=3.0.2; extra == 'build'
|
|
55
57
|
Provides-Extra: compat
|
|
56
58
|
Requires-Dist: pytest-benchmark~=4.0.0; extra == 'compat'
|
|
57
59
|
Requires-Dist: pytest-xdist~=3.6.1; extra == 'compat'
|
|
@@ -46,6 +46,7 @@ dependencies = [
|
|
|
46
46
|
]
|
|
47
47
|
|
|
48
48
|
[project.optional-dependencies]
|
|
49
|
+
build = ["semver>=3.0.2"]
|
|
49
50
|
lint = ["mypy ~= 1.11.2", "ruff ~= 0.6.5"]
|
|
50
51
|
compat = [
|
|
51
52
|
"pytest-benchmark ~= 4.0.0",
|
|
@@ -94,7 +95,7 @@ float_to_top = true
|
|
|
94
95
|
[tool.pytest.ini_options]
|
|
95
96
|
addopts = "--ignore=tests/benchmarks --ignore=tests/examples --ignore=tests/benchmarks/TheAlgorithms"
|
|
96
97
|
filterwarnings = ["ignore::DeprecationWarning:pytest_benchmark.utils.*:"]
|
|
97
|
-
pythonpath = ["tests/benchmarks/TheAlgorithms"]
|
|
98
|
+
pythonpath = ["tests/benchmarks/TheAlgorithms", "./scripts"]
|
|
98
99
|
|
|
99
100
|
[tool.coverage.run]
|
|
100
101
|
branch = true
|
|
@@ -4,7 +4,7 @@ import os
|
|
|
4
4
|
import sys
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
-
from pytest_codspeed import
|
|
7
|
+
from pytest_codspeed import __semver_version__
|
|
8
8
|
from pytest_codspeed.instruments import Instrument
|
|
9
9
|
from pytest_codspeed.instruments.valgrind._wrapper import get_lib
|
|
10
10
|
|
|
@@ -30,7 +30,7 @@ class ValgrindInstrument(Instrument):
|
|
|
30
30
|
if self.should_measure:
|
|
31
31
|
self.lib = get_lib()
|
|
32
32
|
self.lib.dump_stats_at(
|
|
33
|
-
f"Metadata: pytest-codspeed {
|
|
33
|
+
f"Metadata: pytest-codspeed {__semver_version__}".encode("ascii")
|
|
34
34
|
)
|
|
35
35
|
if SUPPORTS_PERF_TRAMPOLINE:
|
|
36
36
|
sys.activate_stack_trampoline("perf") # type: ignore
|
{pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/walltime.py
RENAMED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from dataclasses import asdict, dataclass
|
|
4
4
|
from math import ceil
|
|
5
|
-
from statistics import mean,
|
|
5
|
+
from statistics import mean, quantiles, stdev
|
|
6
6
|
from time import get_clock_info, perf_counter_ns
|
|
7
7
|
from typing import TYPE_CHECKING
|
|
8
8
|
|
|
@@ -40,8 +40,10 @@ class BenchmarkConfig:
|
|
|
40
40
|
if config.warmup_time_ns is not None
|
|
41
41
|
else DEFAULT_WARMUP_TIME_NS,
|
|
42
42
|
min_round_time_ns=DEFAULT_MIN_ROUND_TIME_NS,
|
|
43
|
-
max_time_ns=
|
|
44
|
-
|
|
43
|
+
max_time_ns=config.max_time_ns
|
|
44
|
+
if config.max_time_ns is not None
|
|
45
|
+
else DEFAULT_MAX_TIME_NS,
|
|
46
|
+
max_rounds=config.max_rounds,
|
|
45
47
|
)
|
|
46
48
|
|
|
47
49
|
|
|
@@ -51,7 +53,9 @@ class BenchmarkStats:
|
|
|
51
53
|
max_ns: float
|
|
52
54
|
stdev_ns: float
|
|
53
55
|
mean_ns: float
|
|
56
|
+
q1_ns: float
|
|
54
57
|
median_ns: float
|
|
58
|
+
q3_ns: float
|
|
55
59
|
|
|
56
60
|
rounds: int
|
|
57
61
|
total_time: float
|
|
@@ -71,12 +75,15 @@ class BenchmarkStats:
|
|
|
71
75
|
) -> BenchmarkStats:
|
|
72
76
|
stdev_ns = stdev(times_ns) if len(times_ns) > 1 else 0
|
|
73
77
|
mean_ns = mean(times_ns)
|
|
78
|
+
q1_ns, median_ns, q3_ns = quantiles(times_ns, n=4)
|
|
74
79
|
return cls(
|
|
75
80
|
min_ns=min(times_ns),
|
|
76
81
|
max_ns=max(times_ns),
|
|
77
82
|
stdev_ns=stdev_ns,
|
|
78
83
|
mean_ns=mean_ns,
|
|
79
|
-
median_ns=
|
|
84
|
+
median_ns=median_ns,
|
|
85
|
+
q1_ns=q1_ns,
|
|
86
|
+
q3_ns=q3_ns,
|
|
80
87
|
rounds=rounds,
|
|
81
88
|
total_time=total_time,
|
|
82
89
|
outlier_rounds=sum(1 for t in times_ns if abs(t - mean_ns) > stdev_ns),
|
|
@@ -125,6 +132,7 @@ def run_benchmark(
|
|
|
125
132
|
rounds = int(config.max_time_ns / round_time_ns)
|
|
126
133
|
else:
|
|
127
134
|
rounds = config.max_rounds
|
|
135
|
+
rounds = max(1, rounds)
|
|
128
136
|
|
|
129
137
|
# Benchmark
|
|
130
138
|
iter_range = range(iter_per_round)
|
|
@@ -61,6 +61,15 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
61
61
|
"only for walltime mode"
|
|
62
62
|
),
|
|
63
63
|
)
|
|
64
|
+
group.addoption(
|
|
65
|
+
"--codspeed-max-time",
|
|
66
|
+
action="store",
|
|
67
|
+
type=float,
|
|
68
|
+
help=(
|
|
69
|
+
"The maximum time to run a benchmark for (in seconds), "
|
|
70
|
+
"only for walltime mode"
|
|
71
|
+
),
|
|
72
|
+
)
|
|
64
73
|
group.addoption(
|
|
65
74
|
"--codspeed-max-rounds",
|
|
66
75
|
action="store",
|
|
@@ -75,6 +84,7 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
75
84
|
@dataclass(frozen=True)
|
|
76
85
|
class CodSpeedConfig:
|
|
77
86
|
warmup_time_ns: int | None = None
|
|
87
|
+
max_time_ns: int | None = None
|
|
78
88
|
max_rounds: int | None = None
|
|
79
89
|
|
|
80
90
|
@classmethod
|
|
@@ -83,9 +93,12 @@ class CodSpeedConfig:
|
|
|
83
93
|
warmup_time_ns = (
|
|
84
94
|
int(warmup_time * 1_000_000_000) if warmup_time is not None else None
|
|
85
95
|
)
|
|
96
|
+
max_time = config.getoption("--codspeed-max-time", None)
|
|
97
|
+
max_time_ns = int(max_time * 1_000_000_000) if max_time is not None else None
|
|
86
98
|
return cls(
|
|
87
99
|
warmup_time_ns=warmup_time_ns,
|
|
88
100
|
max_rounds=config.getoption("--codspeed-max-rounds", None),
|
|
101
|
+
max_time_ns=max_time_ns,
|
|
89
102
|
)
|
|
90
103
|
|
|
91
104
|
|
|
@@ -248,15 +261,17 @@ def _measure(
|
|
|
248
261
|
) -> T:
|
|
249
262
|
is_gc_enabled = gc.isenabled()
|
|
250
263
|
if is_gc_enabled:
|
|
251
|
-
|
|
252
|
-
gc.
|
|
264
|
+
pass
|
|
265
|
+
# gc.collect()
|
|
266
|
+
# gc.disable()
|
|
253
267
|
try:
|
|
254
268
|
uri, name = get_git_relative_uri_and_name(nodeid, config.rootpath)
|
|
255
269
|
return plugin.instrument.measure(name, uri, fn, *args, **kwargs)
|
|
256
270
|
finally:
|
|
257
271
|
# Ensure GC is re-enabled even if the test failed
|
|
258
272
|
if is_gc_enabled:
|
|
259
|
-
|
|
273
|
+
pass
|
|
274
|
+
# gc.enable()
|
|
260
275
|
|
|
261
276
|
|
|
262
277
|
def wrap_runtest(
|
|
@@ -5,7 +5,7 @@ import sys
|
|
|
5
5
|
import sysconfig
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
-
from pytest_codspeed import
|
|
8
|
+
from pytest_codspeed import __semver_version__
|
|
9
9
|
|
|
10
10
|
if sys.version_info < (3, 10):
|
|
11
11
|
import importlib_metadata as importlib_metadata
|
|
@@ -51,7 +51,7 @@ def get_environment_metadata() -> dict[str, dict]:
|
|
|
51
51
|
return {
|
|
52
52
|
"creator": {
|
|
53
53
|
"name": "pytest-codspeed",
|
|
54
|
-
"version":
|
|
54
|
+
"version": __semver_version__,
|
|
55
55
|
"pid": os.getpid(),
|
|
56
56
|
},
|
|
57
57
|
"python": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_codspeed-3.0.0b0 → pytest_codspeed-3.0.0b2}/src/pytest_codspeed/instruments/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|