@@ -21,6 +21,22 @@ def __init__(self, obj):
2121 else :
2222 raise ValueError
2323
24+ # Standard deviation
25+ @property
26+ def sd (self ):
27+ return float (self .avg ) * float (self .rel_std_dev ) / 100
28+
29+ # Upper bound of uncertainty interval
30+ @property
31+ def ub (self ):
32+ return float (self .avg ) + self .sd
33+
34+ # Lower bound of uncertainty interval
35+ @property
36+ def lb (self ):
37+ return float (self .avg ) - self .sd
38+
39+
2440class BenchmarkGroup :
2541 def __init__ (self , name ):
2642 self .name = name
@@ -67,6 +83,9 @@ def new_result(self, regex_matches):
6783
6884 def str_compare (self , base , ignore_missing = False ):
6985 output = ""
86+ regs = 0
87+ imps = 0
88+ oks = 0
7089 for group_name , group in self .groups .items ():
7190 base_group = base .groups .get (group_name )
7291 base_max_len = {}
@@ -90,6 +109,22 @@ def str_compare(self, base, ignore_missing=False):
90109 output += " | {avg: ^{avg_len}} {rsd: >{rsd_len}}% | " .format (
91110 avg = base_result .avg , rsd = base_result .rel_std_dev ,
92111 avg_len = base_max_len ["avg" ], rsd_len = base_max_len ["rsd" ])
112+
113+ ub = result .ub
114+ lb = result .lb
115+ base_ub = base_result .ub
116+ base_lb = base_result .lb
117+ if (base_lb < ub < base_ub ) or (base_lb < lb < base_ub ) or (lb < base_ub < ub ) or (lb < base_lb < ub ):
118+ output += "OK\n "
119+ oks += 1
120+ elif float (result .avg ) > float (base_result .avg ):
121+ diff = round ((lb / base_ub - 1 ) * 100 , 2 )
122+ output += "REG +" + str (diff ) + "%\n "
123+ regs += 1
124+ else :
125+ diff = round ((1 - ub / base_lb ) * 100 , 2 )
126+ output += "IMP -" + str (diff ) + "%\n "
127+ imps += 1
93128 else :
94129 output += " | not found in base\n "
95130
@@ -102,6 +137,12 @@ def str_compare(self, base, ignore_missing=False):
102137 output += "warning: following results were found in base benchmarks but not in new:\n "
103138 output += ", " .join (missing_results )
104139 output += "\n "
140+
141+ total_results = imps + oks + regs
142+ output += "\n Out of all compared results:\n "
143+ output += " " + str (regs ) + "/" + str (total_results ) + " regressions\n "
144+ output += " " + str (imps ) + "/" + str (total_results ) + " improvements\n "
145+ output += " " + str (oks ) + "/" + str (total_results ) + " no significant changes"
105146 return output
106147
107148class BenchmarkJSONEncoder (json .JSONEncoder ):
0 commit comments