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

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

Issue 11340037: Chrome remote control multi-page tests: Enable printing out histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
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 math 8 import math
9 9
10 # Valid values of result type. 10 # Valid values of result type.
11 RESULT_TYPES = {'unimportant': 'RESULT ', 11 RESULT_TYPES = {'unimportant': 'RESULT ',
12 'default': '*RESULT ', 12 'default': '*RESULT ',
13 'informational': ''} 13 'informational': '',
14 'unimportant-histogram': 'HISTOGRAM ',
15 'histogram': '*HISTOGRAM '}
14 16
15 17
16 def _EscapePerfResult(s): 18 def _EscapePerfResult(s):
17 """Escapes |s| for use in a perf result.""" 19 """Escapes |s| for use in a perf result."""
18 # Colons (:) and equal signs (=) are not allowed, and we chose an arbitrary 20 # Colons (:) and equal signs (=) are not allowed, and we chose an arbitrary
19 # limit of 40 chars. 21 # limit of 40 chars.
20 return re.sub(':|=', '_', s[:40]) 22 return re.sub(':|=', '_', s[:40])
21 23
22 24
23 def PrintPerfResult(measurement, trace, values, units, result_type='default', 25 def PrintPerfResult(measurement, trace, values, units, result_type='default',
(...skipping 12 matching lines...) Expand all
36 'informational']. 'unimportant' prints RESULT, 'default' prints *RESULT 38 'informational']. 'unimportant' prints RESULT, 'default' prints *RESULT
37 and 'informational' prints nothing. 39 and 'informational' prints nothing.
38 print_to_stdout: If True, prints the output in stdout instead of returning 40 print_to_stdout: If True, prints the output in stdout instead of returning
39 the output to caller. 41 the output to caller.
40 42
41 Returns: 43 Returns:
42 String of the formated perf result. 44 String of the formated perf result.
43 """ 45 """
44 assert result_type in RESULT_TYPES, 'result type: %s is invalid' % result_type 46 assert result_type in RESULT_TYPES, 'result type: %s is invalid' % result_type
45 47
46 assert isinstance(values, list) 48 if (result_type == 'unimportant' or result_type == 'default' or
47 assert len(values) 49 result_type == 'informational'):
tonyg 2012/10/30 15:52:59 if result_type in ['unimportant', 'default', 'info
marja 2012/10/30 17:19:01 Done.
48 assert '/' not in measurement 50 assert isinstance(values, list)
49 avg = None 51 assert len(values)
50 sd = None 52 assert '/' not in measurement
51 if len(values) > 1: 53 avg = None
52 try: 54 sd = None
53 value = '[%s]' % ','.join([str(v) for v in values]) 55 if len(values) > 1:
54 avg = sum([float(v) for v in values]) / len(values) 56 try:
55 sqdiffs = [(float(v) - avg) ** 2 for v in values] 57 value = '[%s]' % ','.join([str(v) for v in values])
56 variance = sum(sqdiffs) / (len(values) - 1) 58 avg = sum([float(v) for v in values]) / len(values)
57 sd = math.sqrt(variance) 59 sqdiffs = [(float(v) - avg) ** 2 for v in values]
58 except ValueError: 60 variance = sum(sqdiffs) / (len(values) - 1)
59 value = ", ".join(values) 61 sd = math.sqrt(variance)
62 except ValueError:
63 value = ", ".join(values)
64 else:
65 value = values[0]
60 else: 66 else:
61 value = values[0] 67 value = values
68 avg = None
tonyg 2012/10/30 15:52:59 Is it too much code to go ahead and calculate the
marja 2012/10/30 17:19:01 Duplicated the code from the page cycler log parse
69 sd = None
62 70
63 trace_name = _EscapePerfResult(trace) 71 trace_name = _EscapePerfResult(trace)
64 output = '%s%s: %s%s%s %s' % ( 72 output = '%s%s: %s%s%s %s' % (
65 RESULT_TYPES[result_type], 73 RESULT_TYPES[result_type],
66 _EscapePerfResult(measurement), 74 _EscapePerfResult(measurement),
67 trace_name, 75 trace_name,
68 # Do not show equal sign if the trace is empty. Usually it happens when 76 # Do not show equal sign if the trace is empty. Usually it happens when
69 # measurement is enough clear to describe the result. 77 # measurement is enough clear to describe the result.
70 '= ' if trace_name else '', 78 '= ' if trace_name else '',
71 value, 79 value,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 def TearDown(self): 119 def TearDown(self):
112 """Tears down performance tests.""" 120 """Tears down performance tests."""
113 if self._original_scaling_governor: 121 if self._original_scaling_governor:
114 self._SetScalingGovernorInternal(self._original_scaling_governor) 122 self._SetScalingGovernorInternal(self._original_scaling_governor)
115 self._original_scaling_governor = None 123 self._original_scaling_governor = None
116 124
117 def _SetScalingGovernorInternal(self, value): 125 def _SetScalingGovernorInternal(self, value):
118 for cpu in range(self._num_cpus): 126 for cpu in range(self._num_cpus):
119 self._adb.RunShellCommand( 127 self._adb.RunShellCommand(
120 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu)) 128 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698