Skip to content

Commit 85260ca

Browse files
committed
[benchmark] Dubious indicator for changes only
Display the `(?)` indicator for dubious result only for changes, never for the unchanged results. Refactored `ResultComparison.init` with simplyfied range check.
1 parent 3f93e31 commit 85260ca

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

benchmark/scripts/compare_perf_tests.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -329,24 +329,24 @@ class ResultComparison(object):
329329
It computes speedup ratio and improvement delta (%).
330330
"""
331331

332-
def __init__(self, old, new):
332+
def __init__(self, old_result, new_result):
333333
"""Initialize with old and new `PerformanceTestResult`s to compare."""
334-
self.old = old
335-
self.new = new
336-
assert old.name == new.name
337-
self.name = old.name # Test name, convenience accessor
334+
self.old = old_result
335+
self.new = new_result
336+
assert old_result.name == new_result.name
337+
self.name = old_result.name # Test name, convenience accessor
338338

339-
# Speedup ratio
340-
self.ratio = (old.min + 0.001) / (new.min + 0.001)
339+
# Location estimates + "epsilon" to prevent division by 0
340+
old = old_result.min + 0.001
341+
new = new_result.min + 0.001
341342

342-
# Test runtime improvement in %
343-
ratio = (new.min + 0.001) / (old.min + 0.001)
344-
self.delta = ((ratio - 1) * 100)
343+
self.ratio = old / new # Speedup ratio
344+
self.delta = ((new / old) - 1) * 100 # Test runtime improvement in %
345345

346-
# Indication of dubious changes: when result's MIN falls inside the
347-
# (MIN, MAX) interval of result they are being compared with.
348-
self.is_dubious = ((old.min < new.min and new.min < old.max) or
349-
(new.min < old.min and old.min < new.max))
346+
# Indication of dubious changes: when results' ranges overlap
347+
o_min, o_max, n_min, n_max = \
348+
self.old.min, self.old.max, self.new.min, self.new.max
349+
self.is_dubious = (o_min <= n_max and n_min <= o_max)
350350

351351

352352
class LogParser(object):
@@ -695,11 +695,16 @@ def format_columns(r, is_strong):
695695
return (r if not is_strong else
696696
r[:-1] + (bold_first(r[-1]), ))
697697

698-
def table(title, results, is_strong=False, is_open=False):
698+
def table(title, results, is_strong=False, is_open=False,
699+
mark_dubious=True):
699700
if not results:
700701
return ''
702+
703+
def dubious(r):
704+
return ventile_formatter(r) if mark_dubious else ''
705+
701706
rows = [row(format_columns(
702-
ReportFormatter.values(r, ventile_formatter), is_strong))
707+
ReportFormatter.values(r, dubious), is_strong))
703708
for r in results]
704709
table = (header(title if self.single_table else '',
705710
ReportFormatter.header_for(results[0])) +
@@ -712,7 +717,8 @@ def table(title, results, is_strong=False, is_open=False):
712717
table('Regression', self.comparator.decreased, True, True),
713718
table('Improvement', self.comparator.increased, True),
714719
('' if self.changes_only else
715-
table('No Changes', self.comparator.unchanged)),
720+
table('No Changes', self.comparator.unchanged,
721+
mark_dubious=False)),
716722
table('Added', self.comparator.added, is_open=True),
717723
table('Removed', self.comparator.removed, is_open=True)
718724
])
@@ -771,9 +777,12 @@ def row(name, old, new, delta, speedup, speedup_color):
771777
def header(contents):
772778
return self.HTML_HEADER_ROW.format(* contents)
773779

774-
def table(title, results, speedup_color):
780+
def table(title, results, speedup_color, mark_dubious=True):
781+
def dubious(r):
782+
return ' (?)' if mark_dubious else ''
783+
775784
rows = [
776-
row(*(ReportFormatter.values(r) + (speedup_color,)))
785+
row(*(ReportFormatter.values(r, dubious) + (speedup_color,)))
777786
for r in results
778787
]
779788
return ('' if not rows else
@@ -786,7 +795,8 @@ def table(title, results, speedup_color):
786795
table('Regression', self.comparator.decreased, 'red'),
787796
table('Improvement', self.comparator.increased, 'green'),
788797
('' if self.changes_only else
789-
table('No Changes', self.comparator.unchanged, 'black')),
798+
table('No Changes', self.comparator.unchanged, 'black',
799+
mark_dubious=False)),
790800
table('Added', self.comparator.added, ''),
791801
table('Removed', self.comparator.removed, '')
792802
]))

benchmark/scripts/test_compare_perf_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,14 @@ def test_emphasize_speedup(self):
941941
<td align='left'>10458</td>
942942
<td align='left'>+0.0%</td>
943943
<td align='left'><font color='black'>1.00x</font></td>
944+
</tr>""",
945+
"""
946+
<tr>
947+
<td align='left'>ArrayAppend</td>
948+
<td align='left'>23641</td>
949+
<td align='left'>20000</td>
950+
<td align='left'>-15.4%</td>
951+
<td align='left'><font color='green'>1.18x (?)</font></td>
944952
</tr>"""
945953
])
946954

0 commit comments

Comments
 (0)