Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Expose calc_geomean function
Browse files Browse the repository at this point in the history
Expose calc_geomean to other packages so that it can used when plotting graph.

git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@216545 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kongy committed Aug 27, 2014
1 parent e4410b5 commit 30195c0
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions lnt/server/reporting/analysis.py
Expand Up @@ -11,6 +11,22 @@
UNCHANGED_PASS = 'UNCHANGED_PASS'
UNCHANGED_FAIL = 'UNCHANGED_FAIL'

def calc_geomean(run_values):
# NOTE Geometric mean applied only to positive values, so fix it by
# adding MIN_VALUE to each value and substract it from the result.
# Since we are only interested in the change of the central tendency,
# this workaround is good enough.

# Smallest possible change we ever look for.
MIN_VALUE = 0.00001

values = [v + MIN_VALUE for v in run_values if v is not None]

if not values:
return None

return util.geometric_mean(values) - MIN_VALUE

class ComparisonResult:
def __init__(self, cur_value, prev_value, delta, pct_delta, stddev, MAD,
cur_failed, prev_failed, samples, prev_samples, stddev_mean = None,
Expand Down Expand Up @@ -239,21 +255,6 @@ def get_comparison_result(self, runs, compare_runs, test_id, field):
run_failed, prev_failed, run_values,
prev_values, stddev_mean, self.confidence_lv)

def _calc_geomean(self, run_values):
# NOTE Geometric mean applied only to positive values, so fix it by
# adding MIN_VALUE to each value and substract it from the result.
# Since we are only interested in the change of the central tendency,
# this workaround is good enough.

# Smallest possible change we ever look for.
MIN_VALUE = 0.00001

values = [v + MIN_VALUE for v in run_values if v is not None]

if not values:
return None

return util.geometric_mean(values) - MIN_VALUE

def get_geomean_comparison_result(self, run, compare_to, field, tests,
comparison_window=[]):
Expand All @@ -262,8 +263,8 @@ def get_geomean_comparison_result(self, run, compare_to, field, tests,
else:
prev_values,run_values = [], []

run_geomean = self._calc_geomean(run_values)
prev_geomean = self._calc_geomean(prev_values)
run_geomean = calc_geomean(run_values)
prev_geomean = calc_geomean(prev_values)

if run_geomean and prev_geomean:
delta = run_geomean - prev_geomean
Expand Down

0 comments on commit 30195c0

Please sign in to comment.