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

4949
5050
5151 class CompareResult(object):
52- def __init__(self, ref, changed):
52+ def __init__(self, ref, changed, min_speed=None):
5353 # CompareData object
5454 self.ref = ref
5555 # CompareData object
5656 self.changed = changed
57+ self._min_speed = min_speed
5758 self._significant = None
5859 self._t_score = None
5960 self._speed = None
6768 bench2 = self.changed.benchmark
6869 self._significant, self._t_score = is_significant_benchs(bench1, bench2)
6970
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+
7079 @property
7180 def significant(self):
7281 if self._significant is None:
144153 return '<CompareResult %r>' % (list(self),)
145154
146155
147-def compare_benchmarks(name, benchmarks):
156+def compare_benchmarks(name, benchmarks, min_speed):
148157 results = CompareResults(name)
149158
150159 ref_item = benchmarks[0]
152161
153162 for item in benchmarks[1:]:
154163 changed = CompareData(item.filename, item.benchmark)
155- result = CompareResult(ref, changed)
164+ result = CompareResult(ref, changed, min_speed)
156165 results.append(result)
157166
158167 return results
289298 not_significant.append(results.name)
290299 continue
291300
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-
297301 item = (results.name, result)
302+ speed = result.speed
298303 if speed == 1.0:
299304 same.append(item)
300305 elif speed > 1.0:
337342 all_results = []
338343 for item in grouped_by_name:
339344 cmp_benchmarks = item.benchmarks
340- results = compare_benchmarks(item.name, cmp_benchmarks)
345+ results = compare_benchmarks(item.name, cmp_benchmarks,
346+ args.min_speed)
341347 all_results.append(results)
342348
343349 show_name = (len(grouped_by_name) > 1)

The check that tells the two apart

failpass·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