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

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

Issue 8383020: Upstream: Android Test scripts (phase 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 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 | build/android/test_package.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import re
7
8
9 def _EscapePerfResult(s):
10 """Escapes |s| for use in a perf result."""
11 # Colons (:) and equal signs (=) are not allowed, and we chose an arbitrary
12 # limit of 40 chars.
13 return re.sub(':|=', '_', s[:40])
14
15
16 def PrintPerfResult(measurement, trace, values, units, important=True,
17 print_to_stdout=True):
18 """Prints numerical data to stdout in the format required by perf tests.
19
20 The string args may be empty but they must not contain any colons (:) or
21 equals signs (=).
22
23 Args:
24 measurement: A description of the quantity being measured, e.g. "vm_peak".
25 trace: A description of the particular data point, e.g. "reference".
26 values: A list of numeric measured values.
27 units: A description of the units of measure, e.g. "bytes".
28 important: If True, the output line will be specially marked, to notify the
29 post-processor.
30
31 Returns:
32 String of the formated perf result.
33 """
34 important_marker = '*' if important else ''
35
36 assert isinstance(values, list)
37 assert len(values)
38 assert '/' not in measurement
39 avg = None
40 if len(values) > 1:
41 try:
42 value = '[%s]' % ','.join([str(v) for v in values])
43 avg = sum([float(v) for v in values]) / len(values)
44 except ValueError:
45 value = ", ".join(values)
46 else:
47 value = values[0]
48
49 output = '%sRESULT %s: %s= %s %s' % (important_marker,
50 _EscapePerfResult(measurement),
51 _EscapePerfResult(trace),
52 value, units)
53 if avg:
54 output += '\nAvg %s: %d%s' % (measurement, avg, units)
55 if print_to_stdout:
56 print output
57 return output
OLDNEW
« no previous file with comments | « no previous file | build/android/test_package.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698