Chromium Code Reviews| Index: build/android/pylib/perf_tests_helper.py |
| =================================================================== |
| --- build/android/pylib/perf_tests_helper.py (revision 217866) |
| +++ build/android/pylib/perf_tests_helper.py (working copy) |
| @@ -9,14 +9,15 @@ |
| import json |
| import logging |
| import math |
| +from telemetry.page import result_data_type |
| -# Valid values of result type. |
| -RESULT_TYPES = {'unimportant': 'RESULT ', |
| - 'default': '*RESULT ', |
| - 'informational': '', |
| - 'unimportant-histogram': 'HISTOGRAM ', |
| - 'histogram': '*HISTOGRAM '} |
| +# Mapping from result type to test output |
| +RESULT_TYPES = {result_data_type.UNIMPORTANT: 'RESULT ', |
| + result_data_type.DEFAULT: '*RESULT ', |
| + result_data_type.INFORMATIONAL: '', |
| + result_data_type.UNIMPORTANT_HISTOGRAM: 'HISTOGRAM ', |
| + result_data_type.HISTOGRAM: '*HISTOGRAM '} |
| def _EscapePerfResult(s): |
| """Escapes |s| for use in a perf result.""" |
| @@ -83,7 +84,8 @@ |
| print 'Pages: [%s]' % ','.join([_EscapePerfResult(p) for p in page_list]) |
| -def PrintPerfResult(measurement, trace, values, units, result_type='default', |
| +def PrintPerfResult(measurement, trace, values, units, |
| + result_type=result_data_type.DEFAULT, |
| print_to_stdout=True): |
| """Prints numerical data to stdout in the format required by perf tests. |
| @@ -96,18 +98,21 @@ |
| values: A list of numeric measured values. An N-dimensional list will be |
| flattened and treated as a simple list. |
| units: A description of the units of measure, e.g. "bytes". |
| - result_type: Accepts values of RESULT_TYPES. |
| + result_type: Accepts values of result_data_type.ALL_TYPES. |
| print_to_stdout: If True, prints the output in stdout instead of returning |
| the output to caller. |
| Returns: |
| String of the formated perf result. |
| """ |
| - assert result_type in RESULT_TYPES, 'result type: %s is invalid' % result_type |
| + assert result_data_type.IsValidType(result_type), \ |
|
dtu
2013/08/16 00:40:02
nit: use parentheses instead of \ (Google style gu
|
| + 'result type: %s is invalid' % result_type |
| trace_name = _EscapePerfResult(trace) |
| - if result_type in ['unimportant', 'default', 'informational']: |
| + if (result_type == result_data_type.UNIMPORTANT or |
| + result_type == result_data_type.DEFAULT or |
| + result_type == result_data_type.INFORMATIONAL): |
| assert isinstance(values, list) |
| assert len(values) |
| assert '/' not in measurement |
| @@ -122,7 +127,7 @@ |
| value, |
| units) |
| else: |
| - assert(result_type in ['histogram', 'unimportant-histogram']) |
| + assert result_data_type.IsHistogram(result_type) |
| assert isinstance(values, list) |
| # The histograms can only be printed individually, there's no computation |
| # across different histograms. |