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

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: Created 9 years, 2 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 | build/android/test_package.py » ('j') | build/android/valgrind_tools.py » ('J')
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 """Collection of methods for running perf tests on the legacy browser."""
7
8 import re
9
Nirnimesh 2011/10/25 01:12:37 nit: need another blank line here
michaelbai 2011/10/25 16:23:59 Done.
10 def _EscapePerfResult(s):
11 """Escapes |s| for use in a perf result."""
12 # Colons (:) and equal signs (=) are not allowed, and we chose an arbitrary
13 # limit of 40 chars.
14 return re.sub(':|=', '_', s[:40])
15
16
17 def PrintPerfResult(measurement, trace, values, units, important=True,
18 print_to_stdout=True):
19 """Prints numerical data to stdout in the format required by perf tests.
20
21 The string args may be empty but they must not contain any colons (:) or
22 equals signs (=).
23
24 Args:
25 measurement: A description of the quantity being measured, e.g. "vm_peak".
26 trace: A description of the particular data point, e.g. "reference".
27 values: A list of numeric measured values.
28 units: A description of the units of measure, e.g. "bytes".
29 important: If True, the output line will be specially marked, to notify the
30 post-processor.
31
32 Returns:
33 String of the formated perf result.
34 """
35 important_marker = ''
Nirnimesh 2011/10/25 01:12:37 lines 35-37 can be rewritten as: important_marker
michaelbai 2011/10/25 16:23:59 Done.
36 if important:
37 important_marker = '*'
38
39 assert isinstance(values, list)
40 assert len(values)
41 assert '/' not in measurement
42 avg = None
43 if len(values) > 1:
44 try:
45 value = '[%s]' % ','.join([str(v) for v in values])
46 avg = sum([float(v) for v in values]) / len(values)
47 except ValueError:
48 value = ", ".join(values)
49 else:
50 value = values[0]
51
52 output = '%sRESULT %s: %s= %s %s' % (important_marker,
53 _EscapePerfResult(measurement),
54 _EscapePerfResult(trace),
55 value, units)
56 if avg:
57 output += '\nAvg %s: %d%s' % (measurement, avg, units)
58 if print_to_stdout:
59 print output
60 return output
OLDNEW
« no previous file with comments | « no previous file | build/android/test_package.py » ('j') | build/android/valgrind_tools.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698