Skip to content

Commit 30fd7ef

Browse files
committed
add is new better update logic
1 parent 34acd87 commit 30fd7ef

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

treeherder/perf/stats.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,27 +244,34 @@ def interpret_mann_whitneyu(base, new):
244244
return mann_whitney, mann_stat, mann_pvalue
245245

246246

247-
def is_new_better(delta_value, lower_is_better):
248-
"""This method returns if the new result is better or worse (even if unsure)"""
249-
if delta_value is None:
250-
direction = None
247+
def is_new_better(c_delta, cles, mann_pvalue, lower_is_better, pvalue_threshold=PVALUE_THRESHOLD):
248+
"""This method takes in CLES to measure if meaningful, Mann Whitney p-val for significance as well as Cliff's Delta for change"""
249+
# Possibility Base > than New with a small amount or more significance
250+
if cles > pvalue_threshold and abs(c_delta) > 0.33 and mann_pvalue < pvalue_threshold:
251+
if lower_is_better:
252+
is_new_better = True
253+
direction = "better"
254+
else:
255+
is_new_better = False
256+
direction = "worse"
257+
# Possibility New > Base with a small amount or more significance
258+
if cles < pvalue_threshold and abs(c_delta) > 0.33 and mann_pvalue < pvalue_threshold:
259+
if lower_is_better:
260+
is_new_better = False
261+
direction = "worse"
262+
else:
263+
is_new_better = True
264+
direction = "better"
265+
else:
251266
is_new_better = None
252-
is_new_better = None
253-
if abs(delta_value) < 0.001:
254267
direction = "no change"
255-
elif (lower_is_better and delta_value < 0) or (not lower_is_better and delta_value > 0):
256-
direction = "better"
257-
is_new_better = True
258-
else:
259-
direction = "worse"
260-
is_new_better = False
261268
return direction, is_new_better
262269

263270

264271
def interpret_cles_direction(cles, pvalue_threshold=PVALUE_THRESHOLD):
265272
if cles is None:
266273
return "CLES cannot be interpreted"
267-
if cles >= pvalue_threshold:
274+
if cles > pvalue_threshold:
268275
return f"{cles:.0%} chance a base value is greater than a new value"
269276
else:
270277
return f"{1 - cles:.0%} chance a new value is greater than a base value"

0 commit comments

Comments
 (0)