Refactor perf bisect script _CalculateConfidence method.

 - Adding docstrings
 - Factoring out _CalculateBounds method
 - Bug fix???

BUG=

Review URL: https://codereview.chromium.org/209853009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260241 0039d316-1c4b-4281-b951-d872f2087c98
parent c07e0d2d
...@@ -1375,7 +1375,7 @@ class BisectPerformanceMetrics(object): ...@@ -1375,7 +1375,7 @@ class BisectPerformanceMetrics(object):
return True return True
raise IOError('Missing extracted folder %s ' % output_dir) raise IOError('Missing extracted folder %s ' % output_dir)
except e: except e:
print 'Somewthing went wrong while extracting archive file: %s' % e print 'Something went wrong while extracting archive file: %s' % e
self.BackupOrRestoreOutputdirectory(restore=True) self.BackupOrRestoreOutputdirectory(restore=True)
# Cleanup any leftovers from unzipping. # Cleanup any leftovers from unzipping.
if os.path.exists(output_dir): if os.path.exists(output_dir):
...@@ -2788,35 +2788,61 @@ class BisectPerformanceMetrics(object): ...@@ -2788,35 +2788,61 @@ class BisectPerformanceMetrics(object):
return other_regressions return other_regressions
def _CalculateConfidence(self, working_means, broken_means): def _CalculateConfidence(self, working_means, broken_means):
bounds_working = [] """Calculates the confidence percentage.
bounds_broken = []
for m in working_means: This is calculated based on how distinct the values are before and after
current_mean = CalculateTruncatedMean(m, 0) the last broken revision, and how noisy the results are.
if bounds_working:
bounds_working[0] = min(current_mean, bounds_working[0]) Args:
bounds_working[1] = max(current_mean, bounds_working[0]) working_means: A list of lists of "good" result numbers.
else: broken means: A list of lists of "bad" result numbers.
bounds_working = [current_mean, current_mean]
for m in broken_means: Returns:
current_mean = CalculateTruncatedMean(m, 0) A number between in the range [0, 100].
if bounds_broken: """
bounds_broken[0] = min(current_mean, bounds_broken[0]) bounds_working = self._CalculateBounds(working_means)
bounds_broken[1] = max(current_mean, bounds_broken[0]) bounds_broken = self._CalculateBounds(broken_means)
else:
bounds_broken = [current_mean, current_mean]
dist_between_groups = min(math.fabs(bounds_broken[1] - bounds_working[0]), dist_between_groups = min(math.fabs(bounds_broken[1] - bounds_working[0]),
math.fabs(bounds_broken[0] - bounds_working[1])) math.fabs(bounds_broken[0] - bounds_working[1]))
working_mean = sum(working_means, []) working_mean = sum(working_means, [])
broken_mean = sum(broken_means, []) broken_mean = sum(broken_means, [])
len_working_group = CalculateStandardDeviation(working_mean) len_working_group = CalculateStandardDeviation(working_mean)
len_broken_group = CalculateStandardDeviation(broken_mean) len_broken_group = CalculateStandardDeviation(broken_mean)
confidence = (dist_between_groups /
confidence = (dist_between_groups / ( (max(0.0001, (len_broken_group + len_working_group))))
max(0.0001, (len_broken_group + len_working_group ))))
confidence = int(min(1.0, max(confidence, 0.0)) * 100.0) confidence = int(min(1.0, max(confidence, 0.0)) * 100.0)
return confidence return confidence
def _CalculateBounds(self, values_list):
"""Returns the lower/upper bounds for the means of the given value lists.
Args:
values_list: A non-empty list of lists of numbers.
Returns:
A (lower, upper) pair of bounds.
"""
bounds = None
for values in values_list:
mean = CalculateTruncatedMean(values, 0)
if bounds:
bounds[0] = min(mean, bounds[0])
bounds[1] = max(mean, bounds[1])
else:
bounds = (mean, mean)
return bounds
def _GetResultsDict(self, revision_data, revision_data_sorted): def _GetResultsDict(self, revision_data, revision_data_sorted):
"""Makes and returns a dictionary of overall results from the bisect.
Args:
revision_data: The revisions_data dict as returned by the Run method.
revision_data_sorted: A list of pairs from the above dictionary, sorted
in order of commits.
Returns:
A dictionary containing results from the bisect.
"""
# Find range where it possibly broke. # Find range where it possibly broke.
first_working_revision = None first_working_revision = None
first_working_revision_index = -1 first_working_revision_index = -1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment