pytest-codspeed 3.0.0__tar.gz → 3.0.0b0__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.
Files changed (18) hide show
  1. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/PKG-INFO +7 -9
  2. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/README.md +3 -4
  3. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/pyproject.toml +5 -5
  4. pytest_codspeed-3.0.0b0/src/pytest_codspeed/__init__.py +5 -0
  5. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/instruments/valgrind/__init__.py +2 -2
  6. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/instruments/walltime.py +8 -37
  7. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/plugin.py +0 -25
  8. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/utils.py +2 -2
  9. pytest_codspeed-3.0.0/src/pytest_codspeed/__init__.py +0 -7
  10. pytest_codspeed-3.0.0/src/pytest_codspeed/py.typed +0 -0
  11. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/.gitignore +0 -0
  12. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/LICENSE +0 -0
  13. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/instruments/__init__.py +0 -0
  14. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/instruments/valgrind/_wrapper/.gitignore +0 -0
  15. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py +0 -0
  16. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c +0 -0
  17. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.h +0 -0
  18. {pytest_codspeed-3.0.0 → pytest_codspeed-3.0.0b0}/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.0
3
+ Version: 3.0.0b0
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,17 +45,15 @@ 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.9
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'
51
52
  Requires-Dist: pytest>=3.8
52
53
  Requires-Dist: rich>=13.8.1
53
54
  Requires-Dist: setuptools; python_full_version >= '3.12.0'
54
- Provides-Extra: build
55
- Requires-Dist: semver>=3.0.2; extra == 'build'
56
55
  Provides-Extra: compat
57
- Requires-Dist: pytest-benchmark~=5.0.0; extra == 'compat'
56
+ Requires-Dist: pytest-benchmark~=4.0.0; extra == 'compat'
58
57
  Requires-Dist: pytest-xdist~=3.6.1; extra == 'compat'
59
58
  Provides-Extra: lint
60
59
  Requires-Dist: mypy~=1.11.2; extra == 'lint'
@@ -69,7 +68,7 @@ Description-Content-Type: text/markdown
69
68
 
70
69
  [![CI](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml/badge.svg)](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
71
70
  [![PyPi Version](https://img.shields.io/pypi/v/pytest-codspeed?color=%2334D058&label=pypi)](https://pypi.org/project/pytest-codspeed)
72
- ![Python Version](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-informational.svg)
71
+ ![Python Version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-informational.svg)
73
72
  [![Discord](https://img.shields.io/badge/chat%20on-discord-7289da.svg)](https://discord.com/invite/MxpaCfKSqF)
74
73
  [![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/CodSpeedHQ/pytest-codspeed)
75
74
 
@@ -79,7 +78,7 @@ Pytest plugin to create CodSpeed benchmarks
79
78
 
80
79
  ## Requirements
81
80
 
82
- **Python**: 3.9 and later
81
+ **Python**: 3.8 and later
83
82
 
84
83
  **pytest**: any recent version
85
84
 
@@ -154,7 +153,7 @@ You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run
154
153
  Example workflow:
155
154
 
156
155
  ```yaml
157
- name: CodSpeed
156
+ name: benchmarks
158
157
 
159
158
  on:
160
159
  push:
@@ -164,7 +163,6 @@ on:
164
163
 
165
164
  jobs:
166
165
  benchmarks:
167
- name: Run benchmarks
168
166
  runs-on: ubuntu-latest
169
167
  steps:
170
168
  - uses: actions/checkout@v4
@@ -3,7 +3,7 @@
3
3
 
4
4
  [![CI](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml/badge.svg)](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
5
5
  [![PyPi Version](https://img.shields.io/pypi/v/pytest-codspeed?color=%2334D058&label=pypi)](https://pypi.org/project/pytest-codspeed)
6
- ![Python Version](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-informational.svg)
6
+ ![Python Version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-informational.svg)
7
7
  [![Discord](https://img.shields.io/badge/chat%20on-discord-7289da.svg)](https://discord.com/invite/MxpaCfKSqF)
8
8
  [![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](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.9 and later
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: CodSpeed
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.9"
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",
@@ -45,10 +46,9 @@ dependencies = [
45
46
  ]
46
47
 
47
48
  [project.optional-dependencies]
48
- build = ["semver>=3.0.2"]
49
49
  lint = ["mypy ~= 1.11.2", "ruff ~= 0.6.5"]
50
50
  compat = [
51
- "pytest-benchmark ~= 5.0.0",
51
+ "pytest-benchmark ~= 4.0.0",
52
52
  "pytest-xdist ~= 3.6.1",
53
53
  # "pytest-speed>=0.3.5",
54
54
  ]
@@ -64,7 +64,7 @@ features = ["lint", "test", "compat"]
64
64
  features = ["test"]
65
65
 
66
66
  [[tool.hatch.envs.test.matrix]]
67
- python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
67
+ python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
68
68
  features = ["compat", "test"]
69
69
 
70
70
  [tool.hatch.version]
@@ -94,7 +94,7 @@ float_to_top = true
94
94
  [tool.pytest.ini_options]
95
95
  addopts = "--ignore=tests/benchmarks --ignore=tests/examples --ignore=tests/benchmarks/TheAlgorithms"
96
96
  filterwarnings = ["ignore::DeprecationWarning:pytest_benchmark.utils.*:"]
97
- pythonpath = ["tests/benchmarks/TheAlgorithms", "./scripts"]
97
+ pythonpath = ["tests/benchmarks/TheAlgorithms"]
98
98
 
99
99
  [tool.coverage.run]
100
100
  branch = true
@@ -0,0 +1,5 @@
1
+ __version__ = "3.0.0b0"
2
+
3
+ from .plugin import BenchmarkFixture
4
+
5
+ __all__ = ["BenchmarkFixture", "__version__"]
@@ -4,7 +4,7 @@ import os
4
4
  import sys
5
5
  from typing import TYPE_CHECKING
6
6
 
7
- from pytest_codspeed import __semver_version__
7
+ from pytest_codspeed import __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 {__semver_version__}".encode("ascii")
33
+ f"Metadata: pytest-codspeed {__version__}".encode("ascii")
34
34
  )
35
35
  if SUPPORTS_PERF_TRAMPOLINE:
36
36
  sys.activate_stack_trampoline("perf") # type: ignore
@@ -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, quantiles, stdev
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=config.max_time_ns
45
- if config.max_time_ns is not None
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
- iqr_outlier_rounds: int
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
- q1_ns=q1_ns,
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
- iqr_outlier_rounds=iqr_outlier_rounds,
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
- escape(bench.name),
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
 
@@ -5,7 +5,7 @@ import sys
5
5
  import sysconfig
6
6
  from pathlib import Path
7
7
 
8
- from pytest_codspeed import __semver_version__
8
+ from pytest_codspeed import __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": __semver_version__,
54
+ "version": __version__,
55
55
  "pid": os.getpid(),
56
56
  },
57
57
  "python": {
@@ -1,7 +0,0 @@
1
- __version__ = "3.0.0"
2
- # We also have the semver version since __version__ is not semver compliant
3
- __semver_version__ = "3.0.0"
4
-
5
- from .plugin import BenchmarkFixture
6
-
7
- __all__ = ["BenchmarkFixture", "__version__", "__semver_version__"]
File without changes