Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1247)

Side by Side Diff: build/android/pylib/perf_tests_helper.py

Issue 11413144: Fix histogram printing for Telemetry tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed fix Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 6
7 import android_commands 7 import android_commands
8 import json 8 import json
9 import math 9 import math
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 """Prints numerical data to stdout in the format required by perf tests. 69 """Prints numerical data to stdout in the format required by perf tests.
70 70
71 The string args may be empty but they must not contain any colons (:) or 71 The string args may be empty but they must not contain any colons (:) or
72 equals signs (=). 72 equals signs (=).
73 73
74 Args: 74 Args:
75 measurement: A description of the quantity being measured, e.g. "vm_peak". 75 measurement: A description of the quantity being measured, e.g. "vm_peak".
76 trace: A description of the particular data point, e.g. "reference". 76 trace: A description of the particular data point, e.g. "reference".
77 values: A list of numeric measured values. 77 values: A list of numeric measured values.
78 units: A description of the units of measure, e.g. "bytes". 78 units: A description of the units of measure, e.g. "bytes".
79 result_type: A tri-state that accepts values of ['unimportant', 'default', 79 result_type: Accepts values of RESULT_TYPES.
80 'informational']. 'unimportant' prints RESULT, 'default' prints *RESULT
81 and 'informational' prints nothing.
82 print_to_stdout: If True, prints the output in stdout instead of returning 80 print_to_stdout: If True, prints the output in stdout instead of returning
83 the output to caller. 81 the output to caller.
84 82
85 Returns: 83 Returns:
86 String of the formated perf result. 84 String of the formated perf result.
87 """ 85 """
88 assert result_type in RESULT_TYPES, 'result type: %s is invalid' % result_type 86 assert result_type in RESULT_TYPES, 'result type: %s is invalid' % result_type
89 87
88 trace_name = _EscapePerfResult(trace)
89
90 if result_type in ['unimportant', 'default', 'informational']: 90 if result_type in ['unimportant', 'default', 'informational']:
91 assert isinstance(values, list) 91 assert isinstance(values, list)
92 assert len(values) 92 assert len(values)
93 assert '/' not in measurement 93 assert '/' not in measurement
94 value, avg, sd = _MeanAndStdDevFromList(values) 94 value, avg, sd = _MeanAndStdDevFromList(values)
95 output = '%s%s: %s%s%s %s' % (
96 RESULT_TYPES[result_type],
97 _EscapePerfResult(measurement),
98 trace_name,
99 # Do not show equal sign if the trace is empty. Usually it happens when
100 # measurement is enough clear to describe the result.
101 '= ' if trace_name else '',
102 value,
103 units)
95 else: 104 else:
96 value = values[0] 105 assert(result_type in ['histogram', 'unimportant-histogram'])
97 # We can't print the units, otherwise parsing the histogram json output 106 assert isinstance(values, list)
98 # can't be parsed easily. 107 assert len(values)
99 units = '' 108 # Print out each histogram separately. We can't print the units, otherwise
100 avg, sd = GeomMeanAndStdDevFromHistogram(value) 109 # the histogram json output can't be parsed easily.
110 output = ''
111 ix = 1
112 for value in values:
113 name = '%s.%s_%d' % (_EscapePerfResult(measurement), trace_name, ix)
114 output += '%s%s%s : %s = %s' % (
115 '\n' if ix > 1 else '',
116 RESULT_TYPES[result_type],
117 name,
118 name,
119 value)
120 ix += 1
121 measurement = '%s.%s' % (measurement, trace_name)
122 means_and_sds = [GeomMeanAndStdDevFromHistogram(value) for value in values]
123 _, avg, sd = _MeanAndStdDevFromList([mean for (mean, _) in means_and_sds ])
101 124
102 trace_name = _EscapePerfResult(trace)
103 output = '%s%s: %s%s%s %s' % (
104 RESULT_TYPES[result_type],
105 _EscapePerfResult(measurement),
106 trace_name,
107 # Do not show equal sign if the trace is empty. Usually it happens when
108 # measurement is enough clear to describe the result.
109 '= ' if trace_name else '',
110 value,
111 units)
112 if avg: 125 if avg:
113 output += '\nAvg %s: %f%s' % (measurement, avg, units) 126 output += '\nAvg %s: %f%s' % (measurement, avg, units)
114 if sd: 127 if sd:
115 output += '\nSd %s: %f%s' % (measurement, sd, units) 128 output += '\nSd %s: %f%s' % (measurement, sd, units)
116 if print_to_stdout: 129 if print_to_stdout:
117 print output 130 print output
118 return output 131 return output
119 132
120 133
121 class PerfTestSetup(object): 134 class PerfTestSetup(object):
(...skipping 28 matching lines...) Expand all
150 def TearDown(self): 163 def TearDown(self):
151 """Tears down performance tests.""" 164 """Tears down performance tests."""
152 if self._original_scaling_governor: 165 if self._original_scaling_governor:
153 self._SetScalingGovernorInternal(self._original_scaling_governor) 166 self._SetScalingGovernorInternal(self._original_scaling_governor)
154 self._original_scaling_governor = None 167 self._original_scaling_governor = None
155 168
156 def _SetScalingGovernorInternal(self, value): 169 def _SetScalingGovernorInternal(self, value):
157 for cpu in range(self._num_cpus): 170 for cpu in range(self._num_cpus):
158 self._adb.RunShellCommand( 171 self._adb.RunShellCommand(
159 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu)) 172 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698