Chromium Code Reviews| Index: build/android/pylib/perf_tests_helper.py |
| =================================================================== |
| --- build/android/pylib/perf_tests_helper.py (revision 218037) |
| +++ build/android/pylib/perf_tests_helper.py (working copy) |
| @@ -10,14 +10,22 @@ |
| import logging |
| import math |
| -# Valid values of result type. |
| -RESULT_TYPES = {'unimportant': 'RESULT ', |
| - 'default': '*RESULT ', |
| - 'informational': '', |
| - 'unimportant-histogram': 'HISTOGRAM ', |
| - 'histogram': '*HISTOGRAM '} |
| +sys.path.append( |
| + os.path.abspath(os.path.join(os.path.dirname(__file__), |
| + os.pardir, os.pardir, os.pardir, |
| + 'tools', 'telemetry'))) |
|
bulach
2013/08/19 08:37:58
hmm, this is dodgy :)
tools/telemetry already dep
|
| +from telemetry.page import result_data_type |
| + |
| + |
| +# 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.""" |
| return re.sub('[\:|=/#&,]', '_', s) |
| @@ -83,7 +91,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 +105,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), |
| + '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 +134,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. |