| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 import sys | 6 import sys |
| 7 | 7 |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import math | 10 import math |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 values: A list of numeric measured values. An N-dimensional list will be | 99 values: A list of numeric measured values. An N-dimensional list will be |
| 100 flattened and treated as a simple list. | 100 flattened and treated as a simple list. |
| 101 units: A description of the units of measure, e.g. "bytes". | 101 units: A description of the units of measure, e.g. "bytes". |
| 102 result_type: Accepts values of perf_result_data_type.ALL_TYPES. | 102 result_type: Accepts values of perf_result_data_type.ALL_TYPES. |
| 103 print_to_stdout: If True, prints the output in stdout instead of returning | 103 print_to_stdout: If True, prints the output in stdout instead of returning |
| 104 the output to caller. | 104 the output to caller. |
| 105 | 105 |
| 106 Returns: | 106 Returns: |
| 107 String of the formated perf result. | 107 String of the formated perf result. |
| 108 """ | 108 """ |
| 109 assert (perf_result_data_type.IsValidType(result_type), | 109 assert perf_result_data_type.IsValidType(result_type), \ |
| 110 'result type: %s is invalid' % result_type) | 110 'result type: %s is invalid' % result_type |
| 111 | 111 |
| 112 trace_name = _EscapePerfResult(trace) | 112 trace_name = _EscapePerfResult(trace) |
| 113 | 113 |
| 114 if (result_type == perf_result_data_type.UNIMPORTANT or | 114 if (result_type == perf_result_data_type.UNIMPORTANT or |
| 115 result_type == perf_result_data_type.DEFAULT or | 115 result_type == perf_result_data_type.DEFAULT or |
| 116 result_type == perf_result_data_type.INFORMATIONAL): | 116 result_type == perf_result_data_type.INFORMATIONAL): |
| 117 assert isinstance(values, list) | 117 assert isinstance(values, list) |
| 118 assert len(values) | 118 assert len(values) |
| 119 assert '/' not in measurement | 119 assert '/' not in measurement |
| 120 value, avg, sd = _MeanAndStdDevFromList(_Flatten(values)) | 120 value, avg, sd = _MeanAndStdDevFromList(_Flatten(values)) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 142 avg, sd = GeomMeanAndStdDevFromHistogram(value) | 142 avg, sd = GeomMeanAndStdDevFromHistogram(value) |
| 143 | 143 |
| 144 if avg: | 144 if avg: |
| 145 output += '\nAvg %s: %f%s' % (measurement, avg, units) | 145 output += '\nAvg %s: %f%s' % (measurement, avg, units) |
| 146 if sd: | 146 if sd: |
| 147 output += '\nSd %s: %f%s' % (measurement, sd, units) | 147 output += '\nSd %s: %f%s' % (measurement, sd, units) |
| 148 if print_to_stdout: | 148 if print_to_stdout: |
| 149 print output | 149 print output |
| 150 sys.stdout.flush() | 150 sys.stdout.flush() |
| 151 return output | 151 return output |
| OLD | NEW |