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

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

Issue 14780004: [Telemetry] Escape URLs in "Pages:" list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Also escape commas Created 7 years, 7 months 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 | tools/telemetry/telemetry/page/page_measurement_results.py » ('j') | 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 import sys 6 import sys
7 7
8 import android_commands 8 import android_commands
9 import json 9 import json
10 import math 10 import math
11 11
12 # Valid values of result type. 12 # Valid values of result type.
13 RESULT_TYPES = {'unimportant': 'RESULT ', 13 RESULT_TYPES = {'unimportant': 'RESULT ',
14 'default': '*RESULT ', 14 'default': '*RESULT ',
15 'informational': '', 15 'informational': '',
16 'unimportant-histogram': 'HISTOGRAM ', 16 'unimportant-histogram': 'HISTOGRAM ',
17 'histogram': '*HISTOGRAM '} 17 'histogram': '*HISTOGRAM '}
18 18
19 19
20 def _EscapePerfResult(s): 20 def _EscapePerfResult(s):
21 """Escapes |s| for use in a perf result.""" 21 """Escapes |s| for use in a perf result."""
22 return re.sub('[\:|=/#&]', '_', s) 22 return re.sub('[\:|=/#&,]', '_', s)
23 23
24 24
25 def GeomMeanAndStdDevFromHistogram(histogram_json): 25 def GeomMeanAndStdDevFromHistogram(histogram_json):
26 histogram = json.loads(histogram_json) 26 histogram = json.loads(histogram_json)
27 # Handle empty histograms gracefully. 27 # Handle empty histograms gracefully.
28 if not 'buckets' in histogram: 28 if not 'buckets' in histogram:
29 return 0.0, 0.0 29 return 0.0, 0.0
30 count = 0 30 count = 0
31 sum_of_logs = 0 31 sum_of_logs = 0
32 for bucket in histogram['buckets']: 32 for bucket in histogram['buckets']:
(...skipping 26 matching lines...) Expand all
59 sqdiffs = [(float(v) - avg) ** 2 for v in values] 59 sqdiffs = [(float(v) - avg) ** 2 for v in values]
60 variance = sum(sqdiffs) / (len(values) - 1) 60 variance = sum(sqdiffs) / (len(values) - 1)
61 sd = math.sqrt(variance) 61 sd = math.sqrt(variance)
62 except ValueError: 62 except ValueError:
63 value = ", ".join(values) 63 value = ", ".join(values)
64 else: 64 else:
65 value = values[0] 65 value = values[0]
66 return value, avg, sd 66 return value, avg, sd
67 67
68 68
69 def PrintPages(page_list):
70 """Prints list of pages to stdout in the format required by perf tests."""
71 print 'Pages: [%s]' % ','.join([_EscapePerfResult(p) for p in page_list])
72
73
69 def PrintPerfResult(measurement, trace, values, units, result_type='default', 74 def PrintPerfResult(measurement, trace, values, units, result_type='default',
70 print_to_stdout=True): 75 print_to_stdout=True):
71 """Prints numerical data to stdout in the format required by perf tests. 76 """Prints numerical data to stdout in the format required by perf tests.
72 77
73 The string args may be empty but they must not contain any colons (:) or 78 The string args may be empty but they must not contain any colons (:) or
74 equals signs (=). 79 equals signs (=).
75 80
76 Args: 81 Args:
77 measurement: A description of the quantity being measured, e.g. "vm_peak". 82 measurement: A description of the quantity being measured, e.g. "vm_peak".
78 trace: A description of the particular data point, e.g. "reference". 83 trace: A description of the particular data point, e.g. "reference".
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 177
173 def RestoreOriginalPerfMode(self): 178 def RestoreOriginalPerfMode(self):
174 """Resets the original performance mode of the device.""" 179 """Resets the original performance mode of the device."""
175 self._SetScalingGovernorInternal(self._original_scaling_governor) 180 self._SetScalingGovernorInternal(self._original_scaling_governor)
176 181
177 def _SetScalingGovernorInternal(self, value): 182 def _SetScalingGovernorInternal(self, value):
178 for cpu in range(self._kernel_max + 1): 183 for cpu in range(self._kernel_max + 1):
179 scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu 184 scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu
180 if self._adb.FileExistsOnDevice(scaling_governor_file): 185 if self._adb.FileExistsOnDevice(scaling_governor_file):
181 self._adb.SetProtectedFileContents(scaling_governor_file, value) 186 self._adb.SetProtectedFileContents(scaling_governor_file, value)
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/page_measurement_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698