pytest-codspeed 3.0.0b2__tar.gz → 3.0.0b4__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 (16) hide show
  1. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/PKG-INFO +1 -1
  2. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/__init__.py +2 -2
  3. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/walltime.py +27 -6
  4. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/plugin.py +3 -5
  5. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/.gitignore +0 -0
  6. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/LICENSE +0 -0
  7. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/README.md +0 -0
  8. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/pyproject.toml +0 -0
  9. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/__init__.py +0 -0
  10. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/valgrind/__init__.py +0 -0
  11. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/valgrind/_wrapper/.gitignore +0 -0
  12. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py +0 -0
  13. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c +0 -0
  14. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.h +0 -0
  15. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.pyi +0 -0
  16. {pytest_codspeed-3.0.0b2 → pytest_codspeed-3.0.0b4}/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.0b2
3
+ Version: 3.0.0b4
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/
@@ -1,6 +1,6 @@
1
- __version__ = "3.0.0b2"
1
+ __version__ = "3.0.0b4"
2
2
  # We also have the semver version since __version__ is not semver compliant
3
- __semver_version__ = "3.0.0-b2"
3
+ __semver_version__ = "3.0.0-b4"
4
4
 
5
5
  from .plugin import BenchmarkFixture
6
6
 
@@ -7,6 +7,7 @@ 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
10
11
  from rich.table import Table
11
12
  from rich.text import Text
12
13
 
@@ -51,15 +52,17 @@ class BenchmarkConfig:
51
52
  class BenchmarkStats:
52
53
  min_ns: float
53
54
  max_ns: float
54
- stdev_ns: float
55
55
  mean_ns: float
56
+ stdev_ns: float
57
+
56
58
  q1_ns: float
57
59
  median_ns: float
58
60
  q3_ns: float
59
61
 
60
62
  rounds: int
61
63
  total_time: float
62
- outlier_rounds: int
64
+ iqr_outlier_rounds: int
65
+ stdev_outlier_rounds: int
63
66
  iter_per_round: int
64
67
  warmup_iters: int
65
68
 
@@ -75,18 +78,36 @@ class BenchmarkStats:
75
78
  ) -> BenchmarkStats:
76
79
  stdev_ns = stdev(times_ns) if len(times_ns) > 1 else 0
77
80
  mean_ns = mean(times_ns)
78
- q1_ns, median_ns, q3_ns = quantiles(times_ns, n=4)
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
+
79
99
  return cls(
80
100
  min_ns=min(times_ns),
81
101
  max_ns=max(times_ns),
82
102
  stdev_ns=stdev_ns,
83
103
  mean_ns=mean_ns,
84
- median_ns=median_ns,
85
104
  q1_ns=q1_ns,
105
+ median_ns=median_ns,
86
106
  q3_ns=q3_ns,
87
107
  rounds=rounds,
88
108
  total_time=total_time,
89
- outlier_rounds=sum(1 for t in times_ns if abs(t - mean_ns) > stdev_ns),
109
+ iqr_outlier_rounds=iqr_outlier_rounds,
110
+ stdev_outlier_rounds=stdev_outlier_rounds,
90
111
  iter_per_round=iter_per_round,
91
112
  warmup_iters=warmup_iters,
92
113
  )
@@ -223,7 +244,7 @@ class WallTimeInstrument(Instrument):
223
244
  if rsd > 0.1:
224
245
  rsd_text.stylize("red bold")
225
246
  table.add_row(
226
- bench.name,
247
+ escape(bench.name),
227
248
  f"{bench.stats.min_ns/bench.stats.iter_per_round:,.0f}ns",
228
249
  rsd_text,
229
250
  f"{bench.stats.total_time:,.2f}s",
@@ -261,17 +261,15 @@ def _measure(
261
261
  ) -> T:
262
262
  is_gc_enabled = gc.isenabled()
263
263
  if is_gc_enabled:
264
- pass
265
- # gc.collect()
266
- # gc.disable()
264
+ gc.collect()
265
+ gc.disable()
267
266
  try:
268
267
  uri, name = get_git_relative_uri_and_name(nodeid, config.rootpath)
269
268
  return plugin.instrument.measure(name, uri, fn, *args, **kwargs)
270
269
  finally:
271
270
  # Ensure GC is re-enabled even if the test failed
272
271
  if is_gc_enabled:
273
- pass
274
- # gc.enable()
272
+ gc.enable()
275
273
 
276
274
 
277
275
  def wrap_runtest(