pytest-codspeed 3.0.0__tar.gz → 3.0.0b1__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.0 → pytest_codspeed-3.0.0b1}/PKG-INFO +7 -7
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/README.md +3 -4
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/pyproject.toml +4 -3
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/__init__.py +2 -2
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/walltime.py +8 -37
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/plugin.py +0 -25
- pytest_codspeed-3.0.0/src/pytest_codspeed/py.typed +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/.gitignore +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/LICENSE +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/__init__.py +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/valgrind/__init__.py +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/valgrind/_wrapper/.gitignore +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.h +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.pyi +0 -0
- {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/utils.py +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.0b1
|
|
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/
|
|
@@ -35,6 +35,7 @@ Classifier: Intended Audience :: Developers
|
|
|
35
35
|
Classifier: Intended Audience :: Information Technology
|
|
36
36
|
Classifier: License :: OSI Approved :: MIT License
|
|
37
37
|
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
38
39
|
Classifier: Programming Language :: Python :: 3.9
|
|
39
40
|
Classifier: Programming Language :: Python :: 3.10
|
|
40
41
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -44,7 +45,7 @@ Classifier: Topic :: Software Development :: Testing
|
|
|
44
45
|
Classifier: Topic :: System :: Benchmark
|
|
45
46
|
Classifier: Topic :: Utilities
|
|
46
47
|
Classifier: Typing :: Typed
|
|
47
|
-
Requires-Python: >=3.
|
|
48
|
+
Requires-Python: >=3.8
|
|
48
49
|
Requires-Dist: cffi>=1.17.1
|
|
49
50
|
Requires-Dist: filelock>=3.12.2
|
|
50
51
|
Requires-Dist: importlib-metadata>=8.5.0; python_version < '3.10'
|
|
@@ -54,7 +55,7 @@ Requires-Dist: setuptools; python_full_version >= '3.12.0'
|
|
|
54
55
|
Provides-Extra: build
|
|
55
56
|
Requires-Dist: semver>=3.0.2; extra == 'build'
|
|
56
57
|
Provides-Extra: compat
|
|
57
|
-
Requires-Dist: pytest-benchmark~=
|
|
58
|
+
Requires-Dist: pytest-benchmark~=4.0.0; extra == 'compat'
|
|
58
59
|
Requires-Dist: pytest-xdist~=3.6.1; extra == 'compat'
|
|
59
60
|
Provides-Extra: lint
|
|
60
61
|
Requires-Dist: mypy~=1.11.2; extra == 'lint'
|
|
@@ -69,7 +70,7 @@ Description-Content-Type: text/markdown
|
|
|
69
70
|
|
|
70
71
|
[](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
|
|
71
72
|
[](https://pypi.org/project/pytest-codspeed)
|
|
72
|
-

|
|
73
|
+

|
|
73
74
|
[](https://discord.com/invite/MxpaCfKSqF)
|
|
74
75
|
[](https://codspeed.io/CodSpeedHQ/pytest-codspeed)
|
|
75
76
|
|
|
@@ -79,7 +80,7 @@ Pytest plugin to create CodSpeed benchmarks
|
|
|
79
80
|
|
|
80
81
|
## Requirements
|
|
81
82
|
|
|
82
|
-
**Python**: 3.
|
|
83
|
+
**Python**: 3.8 and later
|
|
83
84
|
|
|
84
85
|
**pytest**: any recent version
|
|
85
86
|
|
|
@@ -154,7 +155,7 @@ You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run
|
|
|
154
155
|
Example workflow:
|
|
155
156
|
|
|
156
157
|
```yaml
|
|
157
|
-
name:
|
|
158
|
+
name: benchmarks
|
|
158
159
|
|
|
159
160
|
on:
|
|
160
161
|
push:
|
|
@@ -164,7 +165,6 @@ on:
|
|
|
164
165
|
|
|
165
166
|
jobs:
|
|
166
167
|
benchmarks:
|
|
167
|
-
name: Run benchmarks
|
|
168
168
|
runs-on: ubuntu-latest
|
|
169
169
|
steps:
|
|
170
170
|
- uses: actions/checkout@v4
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
[](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
|
|
5
5
|
[](https://pypi.org/project/pytest-codspeed)
|
|
6
|
-

|
|
6
|
+

|
|
7
7
|
[](https://discord.com/invite/MxpaCfKSqF)
|
|
8
8
|
[](https://codspeed.io/CodSpeedHQ/pytest-codspeed)
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ Pytest plugin to create CodSpeed benchmarks
|
|
|
13
13
|
|
|
14
14
|
## Requirements
|
|
15
15
|
|
|
16
|
-
**Python**: 3.
|
|
16
|
+
**Python**: 3.8 and later
|
|
17
17
|
|
|
18
18
|
**pytest**: any recent version
|
|
19
19
|
|
|
@@ -88,7 +88,7 @@ You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run
|
|
|
88
88
|
Example workflow:
|
|
89
89
|
|
|
90
90
|
```yaml
|
|
91
|
-
name:
|
|
91
|
+
name: benchmarks
|
|
92
92
|
|
|
93
93
|
on:
|
|
94
94
|
push:
|
|
@@ -98,7 +98,6 @@ on:
|
|
|
98
98
|
|
|
99
99
|
jobs:
|
|
100
100
|
benchmarks:
|
|
101
|
-
name: Run benchmarks
|
|
102
101
|
runs-on: ubuntu-latest
|
|
103
102
|
steps:
|
|
104
103
|
- uses: actions/checkout@v4
|
|
@@ -13,7 +13,7 @@ dynamic = ["version"]
|
|
|
13
13
|
description = "Pytest plugin to create CodSpeed benchmarks"
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
license = { file = "LICENSE" }
|
|
16
|
-
requires-python = ">=3.
|
|
16
|
+
requires-python = ">=3.8"
|
|
17
17
|
authors = [{ name = "Arthur Pastel", email = "arthur@codspeed.io" }]
|
|
18
18
|
keywords = ["codspeed", "benchmark", "performance", "pytest"]
|
|
19
19
|
classifiers = [
|
|
@@ -23,6 +23,7 @@ classifiers = [
|
|
|
23
23
|
"Intended Audience :: Information Technology",
|
|
24
24
|
"License :: OSI Approved :: MIT License",
|
|
25
25
|
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.8",
|
|
26
27
|
"Programming Language :: Python :: 3.9",
|
|
27
28
|
"Programming Language :: Python :: 3.10",
|
|
28
29
|
"Programming Language :: Python :: 3.11",
|
|
@@ -48,7 +49,7 @@ dependencies = [
|
|
|
48
49
|
build = ["semver>=3.0.2"]
|
|
49
50
|
lint = ["mypy ~= 1.11.2", "ruff ~= 0.6.5"]
|
|
50
51
|
compat = [
|
|
51
|
-
"pytest-benchmark ~=
|
|
52
|
+
"pytest-benchmark ~= 4.0.0",
|
|
52
53
|
"pytest-xdist ~= 3.6.1",
|
|
53
54
|
# "pytest-speed>=0.3.5",
|
|
54
55
|
]
|
|
@@ -64,7 +65,7 @@ features = ["lint", "test", "compat"]
|
|
|
64
65
|
features = ["test"]
|
|
65
66
|
|
|
66
67
|
[[tool.hatch.envs.test.matrix]]
|
|
67
|
-
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
68
|
+
python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
68
69
|
features = ["compat", "test"]
|
|
69
70
|
|
|
70
71
|
[tool.hatch.version]
|
{pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/src/pytest_codspeed/instruments/walltime.py
RENAMED
|
@@ -2,12 +2,11 @@ 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, median, stdev
|
|
6
6
|
from time import get_clock_info, perf_counter_ns
|
|
7
7
|
from typing import TYPE_CHECKING
|
|
8
8
|
|
|
9
9
|
from rich.console import Console
|
|
10
|
-
from rich.markup import escape
|
|
11
10
|
from rich.table import Table
|
|
12
11
|
from rich.text import Text
|
|
13
12
|
|
|
@@ -41,10 +40,8 @@ class BenchmarkConfig:
|
|
|
41
40
|
if config.warmup_time_ns is not None
|
|
42
41
|
else DEFAULT_WARMUP_TIME_NS,
|
|
43
42
|
min_round_time_ns=DEFAULT_MIN_ROUND_TIME_NS,
|
|
44
|
-
max_time_ns=
|
|
45
|
-
|
|
46
|
-
else DEFAULT_MAX_TIME_NS,
|
|
47
|
-
max_rounds=config.max_rounds,
|
|
43
|
+
max_time_ns=DEFAULT_MAX_TIME_NS,
|
|
44
|
+
max_rounds=config.max_rounds or None,
|
|
48
45
|
)
|
|
49
46
|
|
|
50
47
|
|
|
@@ -52,17 +49,13 @@ class BenchmarkConfig:
|
|
|
52
49
|
class BenchmarkStats:
|
|
53
50
|
min_ns: float
|
|
54
51
|
max_ns: float
|
|
55
|
-
mean_ns: float
|
|
56
52
|
stdev_ns: float
|
|
57
|
-
|
|
58
|
-
q1_ns: float
|
|
53
|
+
mean_ns: float
|
|
59
54
|
median_ns: float
|
|
60
|
-
q3_ns: float
|
|
61
55
|
|
|
62
56
|
rounds: int
|
|
63
57
|
total_time: float
|
|
64
|
-
|
|
65
|
-
stdev_outlier_rounds: int
|
|
58
|
+
outlier_rounds: int
|
|
66
59
|
iter_per_round: int
|
|
67
60
|
warmup_iters: int
|
|
68
61
|
|
|
@@ -78,36 +71,15 @@ class BenchmarkStats:
|
|
|
78
71
|
) -> BenchmarkStats:
|
|
79
72
|
stdev_ns = stdev(times_ns) if len(times_ns) > 1 else 0
|
|
80
73
|
mean_ns = mean(times_ns)
|
|
81
|
-
if len(times_ns) > 1:
|
|
82
|
-
q1_ns, median_ns, q3_ns = quantiles(times_ns, n=4)
|
|
83
|
-
else:
|
|
84
|
-
q1_ns, median_ns, q3_ns = (
|
|
85
|
-
mean_ns,
|
|
86
|
-
mean_ns,
|
|
87
|
-
mean_ns,
|
|
88
|
-
)
|
|
89
|
-
iqr_ns = q3_ns - q1_ns
|
|
90
|
-
iqr_outlier_rounds = sum(
|
|
91
|
-
1 for t in times_ns if t < q1_ns - 1.5 * iqr_ns or t > q3_ns + 1.5 * iqr_ns
|
|
92
|
-
)
|
|
93
|
-
stdev_outlier_rounds = sum(
|
|
94
|
-
1
|
|
95
|
-
for t in times_ns
|
|
96
|
-
if t < mean_ns - 3 * stdev_ns or t > mean_ns + 3 * stdev_ns
|
|
97
|
-
)
|
|
98
|
-
|
|
99
74
|
return cls(
|
|
100
75
|
min_ns=min(times_ns),
|
|
101
76
|
max_ns=max(times_ns),
|
|
102
77
|
stdev_ns=stdev_ns,
|
|
103
78
|
mean_ns=mean_ns,
|
|
104
|
-
|
|
105
|
-
median_ns=median_ns,
|
|
106
|
-
q3_ns=q3_ns,
|
|
79
|
+
median_ns=median(times_ns),
|
|
107
80
|
rounds=rounds,
|
|
108
81
|
total_time=total_time,
|
|
109
|
-
|
|
110
|
-
stdev_outlier_rounds=stdev_outlier_rounds,
|
|
82
|
+
outlier_rounds=sum(1 for t in times_ns if abs(t - mean_ns) > stdev_ns),
|
|
111
83
|
iter_per_round=iter_per_round,
|
|
112
84
|
warmup_iters=warmup_iters,
|
|
113
85
|
)
|
|
@@ -153,7 +125,6 @@ def run_benchmark(
|
|
|
153
125
|
rounds = int(config.max_time_ns / round_time_ns)
|
|
154
126
|
else:
|
|
155
127
|
rounds = config.max_rounds
|
|
156
|
-
rounds = max(1, rounds)
|
|
157
128
|
|
|
158
129
|
# Benchmark
|
|
159
130
|
iter_range = range(iter_per_round)
|
|
@@ -244,7 +215,7 @@ class WallTimeInstrument(Instrument):
|
|
|
244
215
|
if rsd > 0.1:
|
|
245
216
|
rsd_text.stylize("red bold")
|
|
246
217
|
table.add_row(
|
|
247
|
-
|
|
218
|
+
bench.name,
|
|
248
219
|
f"{bench.stats.min_ns/bench.stats.iter_per_round:,.0f}ns",
|
|
249
220
|
rsd_text,
|
|
250
221
|
f"{bench.stats.total_time:,.2f}s",
|
|
@@ -61,15 +61,6 @@ 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
|
-
)
|
|
73
64
|
group.addoption(
|
|
74
65
|
"--codspeed-max-rounds",
|
|
75
66
|
action="store",
|
|
@@ -84,7 +75,6 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
84
75
|
@dataclass(frozen=True)
|
|
85
76
|
class CodSpeedConfig:
|
|
86
77
|
warmup_time_ns: int | None = None
|
|
87
|
-
max_time_ns: int | None = None
|
|
88
78
|
max_rounds: int | None = None
|
|
89
79
|
|
|
90
80
|
@classmethod
|
|
@@ -93,12 +83,9 @@ class CodSpeedConfig:
|
|
|
93
83
|
warmup_time_ns = (
|
|
94
84
|
int(warmup_time * 1_000_000_000) if warmup_time is not None else None
|
|
95
85
|
)
|
|
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
|
|
98
86
|
return cls(
|
|
99
87
|
warmup_time_ns=warmup_time_ns,
|
|
100
88
|
max_rounds=config.getoption("--codspeed-max-rounds", None),
|
|
101
|
-
max_time_ns=max_time_ns,
|
|
102
89
|
)
|
|
103
90
|
|
|
104
91
|
|
|
@@ -320,18 +307,6 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus):
|
|
|
320
307
|
class BenchmarkFixture:
|
|
321
308
|
"""The fixture that can be used to benchmark a function."""
|
|
322
309
|
|
|
323
|
-
@property # type: ignore
|
|
324
|
-
def __class__(self):
|
|
325
|
-
# Bypass the pytest-benchmark fixture class check
|
|
326
|
-
# https://github.com/ionelmc/pytest-benchmark/commit/d6511e3474931feb4e862948128e0c389acfceec
|
|
327
|
-
if IS_PYTEST_BENCHMARK_INSTALLED:
|
|
328
|
-
from pytest_benchmark.fixture import (
|
|
329
|
-
BenchmarkFixture as PytestBenchmarkFixture,
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
return PytestBenchmarkFixture
|
|
333
|
-
return BenchmarkFixture
|
|
334
|
-
|
|
335
310
|
def __init__(self, request: pytest.FixtureRequest):
|
|
336
311
|
self.extra_info: dict = {}
|
|
337
312
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b1}/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
|
|
File without changes
|
|
File without changes
|