| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 from telemetry.page import perf_tests_helper | |
| 5 | |
| 6 def _Mean(l): | |
| 7 return float(sum(l)) / len(l) if len(l) > 0 else 0.0 | |
| 8 | |
| 9 class PageBenchmarkValue(object): | |
| 10 def __init__(self, trace_name, units, value, chart_name, data_type): | |
| 11 self.trace_name = trace_name | |
| 12 self.units = units | |
| 13 self.value = value | |
| 14 self.chart_name = chart_name | |
| 15 self.data_type = data_type | |
| 16 | |
| 17 @property | |
| 18 def measurement_name(self): | |
| 19 if self.chart_name: | |
| 20 return '%s.%s' % (self.chart_name, self.trace_name) | |
| 21 else: | |
| 22 return self.trace_name | |
| 23 | |
| 24 @property | |
| 25 def output_value(self): | |
| 26 if self.data_type == 'histogram': | |
| 27 (mean, _) = perf_tests_helper.GeomMeanAndStdDevFromHistogram(self.value) | |
| 28 return mean | |
| 29 elif isinstance(self.value, list): | |
| 30 return _Mean(self.value) | |
| 31 else: | |
| 32 return self.value | |
| OLD | NEW |