Whole file
psf/pyperf
The author described this change as “Fix compare_suites_list() for min_speed”. It counts as a record because the check below fails on the code as it stood at 564ccc25a and passes on d79e4afc0, with nothing else changed between the two runs.
Projectpsf/pyperf
Fix saved2020-10-14
Sharing licenceMIT · COPYING
Change size+15 −9
What the code was meant to do, written into the code itself as a save note
Fix compare_suites_list() for min_speed
The change
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | 51 | class CompareResult(object): | |
| 52 | - | def __init__(self, ref, changed): | |
| 52 | + | def __init__(self, ref, changed, min_speed=None): | |
| 53 | 53 | # CompareData object | |
| 54 | 54 | self.ref = ref | |
| 55 | 55 | # CompareData object | |
| 56 | 56 | self.changed = changed | |
| 57 | + | self._min_speed = min_speed | |
| 57 | 58 | self._significant = None | |
| 58 | 59 | self._t_score = None | |
| 59 | 60 | self._speed = None | |
| ⋯ | |||
| 67 | 68 | bench2 = self.changed.benchmark | |
| 68 | 69 | self._significant, self._t_score = is_significant_benchs(bench1, bench2) | |
| 69 | 70 | ||
| 71 | + | if self._min_speed is not None: | |
| 72 | + | speed = self.speed | |
| 73 | + | if speed < 1.0: | |
| 74 | + | # slower uses the inverse | |
| 75 | + | speed = 1.0 / speed | |
| 76 | + | if (speed - 1.0) * 100 < self._min_speed: | |
| 77 | + | self._significant = False | |
| 78 | + | ||
| 70 | 79 | @property | |
| 71 | 80 | def significant(self): | |
| 72 | 81 | if self._significant is None: | |
| ⋯ | |||
| 144 | 153 | return '<CompareResult %r>' % (list(self),) | |
| 145 | 154 | ||
| 146 | 155 | ||
| 147 | - | def compare_benchmarks(name, benchmarks): | |
| 156 | + | def compare_benchmarks(name, benchmarks, min_speed): | |
| 148 | 157 | results = CompareResults(name) | |
| 149 | 158 | ||
| 150 | 159 | ref_item = benchmarks[0] | |
| ⋯ | |||
| 152 | 161 | ||
| 153 | 162 | for item in benchmarks[1:]: | |
| 154 | 163 | changed = CompareData(item.filename, item.benchmark) | |
| 155 | - | result = CompareResult(ref, changed) | |
| 164 | + | result = CompareResult(ref, changed, min_speed) | |
| 156 | 165 | results.append(result) | |
| 157 | 166 | ||
| 158 | 167 | return results | |
| ⋯ | |||
| 289 | 298 | not_significant.append(results.name) | |
| 290 | 299 | continue | |
| 291 | 300 | ||
| 292 | - | speed = result.speed | |
| 293 | - | if args.min_speed and abs(speed - 1.0) * 100 < args.min_speed: | |
| 294 | - | not_significant.append(results.name) | |
| 295 | - | continue | |
| 296 | - | ||
| 297 | 301 | item = (results.name, result) | |
| 302 | + | speed = result.speed | |
| 298 | 303 | if speed == 1.0: | |
| 299 | 304 | same.append(item) | |
| 300 | 305 | elif speed > 1.0: | |
| ⋯ | |||
| 337 | 342 | all_results = [] | |
| 338 | 343 | for item in grouped_by_name: | |
| 339 | 344 | cmp_benchmarks = item.benchmarks | |
| 340 | - | results = compare_benchmarks(item.name, cmp_benchmarks) | |
| 345 | + | results = compare_benchmarks(item.name, cmp_benchmarks, | |
| 346 | + | args.min_speed) | |
| 341 | 347 | all_results.append(results) | |
| 342 | 348 | ||
| 343 | 349 | show_name = (len(grouped_by_name) > 1) | |
The check that tells the two apart
fail→pass·pyperf/tests/test_perf_cli.py::TestPerfCLI::test_compare_cli_min_speed
Check file pyperf/tests/test_perf_cli.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it564ccc25a98bdd02686ecf7552891cd61220b457
Broken version dated2020-10-14
Modulepyperf._compare
Units changedCompareResult, compare_benchmarks, compare_suites, compare_suites_by_speed
Fingerprint548314ebbfecadfc
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in psf/pyperf
- 2016-06-09fix very verbose output: runs => samples