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

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: Code review (bulach) Created 8 years, 1 month 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 try: 54 try:
55 value = '[%s]' % ','.join([str(v) for v in values]) 55 value = '[%s]' % ','.join([str(v) for v in values])
56 avg = sum([float(v) for v in values]) / len(values) 56 avg = sum([float(v) for v in values]) / len(values)
57 sqdiffs = [(float(v) - avg) ** 2 for v in values] 57 sqdiffs = [(float(v) - avg) ** 2 for v in values]
58 variance = sum(sqdiffs) / (len(values) - 1) 58 variance = sum(sqdiffs) / (len(values) - 1)
59 sd = math.sqrt(variance) 59 sd = math.sqrt(variance)
60 except ValueError: 60 except ValueError:
61 value = ", ".join(values) 61 value = ", ".join(values)
62 else: 62 else:
63 value = values[0] 63 value = values[0]
64 avg = values[0]
marja 2012/11/27 10:48:30 This was the addition which broke the kraken bench
64 return value, avg, sd 65 return value, avg, sd
65 66
66 67
67 def PrintPerfResult(measurement, trace, values, units, result_type='default', 68 def PrintPerfResult(measurement, trace, values, units, result_type='default',
68 print_to_stdout=True): 69 print_to_stdout=True):
69 """Prints numerical data to stdout in the format required by perf tests. 70 """Prints numerical data to stdout in the format required by perf tests.
70 71
71 The string args may be empty but they must not contain any colons (:) or 72 The string args may be empty but they must not contain any colons (:) or
72 equals signs (=). 73 equals signs (=).
73 74
74 Args: 75 Args:
75 measurement: A description of the quantity being measured, e.g. "vm_peak". 76 measurement: A description of the quantity being measured, e.g. "vm_peak".
76 trace: A description of the particular data point, e.g. "reference". 77 trace: A description of the particular data point, e.g. "reference".
77 values: A list of numeric measured values. 78 values: A list of numeric measured values.
78 units: A description of the units of measure, e.g. "bytes". 79 units: A description of the units of measure, e.g. "bytes".
79 result_type: A tri-state that accepts values of ['unimportant', 'default', 80 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 81 print_to_stdout: If True, prints the output in stdout instead of returning
83 the output to caller. 82 the output to caller.
84 83
85 Returns: 84 Returns:
86 String of the formated perf result. 85 String of the formated perf result.
87 """ 86 """
88 assert result_type in RESULT_TYPES, 'result type: %s is invalid' % result_type 87 assert result_type in RESULT_TYPES, 'result type: %s is invalid' % result_type
89 88
89 trace_name = _EscapePerfResult(trace)
90
90 if result_type in ['unimportant', 'default', 'informational']: 91 if result_type in ['unimportant', 'default', 'informational']:
91 assert isinstance(values, list) 92 assert isinstance(values, list)
92 assert len(values) 93 assert len(values)
93 assert '/' not in measurement 94 assert '/' not in measurement
94 value, avg, sd = _MeanAndStdDevFromList(values) 95 value, avg, sd = _MeanAndStdDevFromList(values)
96 output = '%s%s: %s%s%s %s' % (
97 RESULT_TYPES[result_type],
98 _EscapePerfResult(measurement),
99 trace_name,
100 # Do not show equal sign if the trace is empty. Usually it happens when
101 # measurement is enough clear to describe the result.
102 '= ' if trace_name else '',
103 value,
104 units)
95 else: 105 else:
96 value = values[0] 106 assert(result_type in ['histogram', 'unimportant-histogram'])
97 # We can't print the units, otherwise parsing the histogram json output 107 assert isinstance(values, list)
98 # can't be parsed easily. 108 assert len(values)
99 units = '' 109 # Print out each histogram separately. We can't print the units, otherwise
100 avg, sd = GeomMeanAndStdDevFromHistogram(value) 110 # the histogram json output can't be parsed easily.
111 output = ''
112 ix = 1
113 for value in values:
114 name = '%s.%s_%d' % (_EscapePerfResult(measurement), trace_name, ix)
115 output += '%s%s%s : %s = %s' % (
116 '\n' if ix > 1 else '',
117 RESULT_TYPES[result_type],
118 name,
119 name,
120 value)
121 ix += 1
122 measurement = '%s.%s' % (measurement, trace_name)
123 means_and_sds = [GeomMeanAndStdDevFromHistogram(value) for value in values]
124 _, avg, sd = _MeanAndStdDevFromList([mean for (mean, _) in means_and_sds ])
101 125
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: 126 if avg:
113 output += '\nAvg %s: %f%s' % (measurement, avg, units) 127 output += '\nAvg %s: %f%s' % (measurement, avg, units)
114 if sd: 128 if sd:
115 output += '\nSd %s: %f%s' % (measurement, sd, units) 129 output += '\nSd %s: %f%s' % (measurement, sd, units)
116 if print_to_stdout: 130 if print_to_stdout:
117 print output 131 print output
118 return output 132 return output
119 133
120 134
121 class PerfTestSetup(object): 135 class PerfTestSetup(object):
(...skipping 28 matching lines...) Expand all
150 def TearDown(self): 164 def TearDown(self):
151 """Tears down performance tests.""" 165 """Tears down performance tests."""
152 if self._original_scaling_governor: 166 if self._original_scaling_governor:
153 self._SetScalingGovernorInternal(self._original_scaling_governor) 167 self._SetScalingGovernorInternal(self._original_scaling_governor)
154 self._original_scaling_governor = None 168 self._original_scaling_governor = None
155 169
156 def _SetScalingGovernorInternal(self, value): 170 def _SetScalingGovernorInternal(self, value):
157 for cpu in range(self._num_cpus): 171 for cpu in range(self._num_cpus):
158 self._adb.RunShellCommand( 172 self._adb.RunShellCommand(
159 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu)) 173 ('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