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

Side by Side Diff: mojo/devtools/common/devtoolslib/benchmark.py

Issue 1915443002: Enable the use of spaces within a benchmark measurement name (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « apps/benchmark/run_args.cc ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """Logic that drives runs of the benchmarking mojo app and parses its output.""" 5 """Logic that drives runs of the benchmarking mojo app and parses its output."""
6 6
7 import os.path 7 import os.path
8 import pipes
8 import re 9 import re
9 10
10 _BENCHMARK_APP = 'https://core.mojoapps.io/benchmark.mojo' 11 _BENCHMARK_APP = 'https://core.mojoapps.io/benchmark.mojo'
11 12
12 # Additional time in seconds allocated per shell run to accommodate start-up. 13 # Additional time in seconds allocated per shell run to accommodate start-up.
13 # The shell should terminate before hitting this time out, it is an error if it 14 # The shell should terminate before hitting this time out, it is an error if it
14 # doesn't. 15 # doesn't.
15 _EXTRA_TIMEOUT = 20 16 _EXTRA_TIMEOUT = 20
16 17
17 _MEASUREMENT_RESULT_FORMAT = r""" 18 _MEASUREMENT_RESULT_FORMAT = r"""
18 ^ # Beginning of the line. 19 ^ # Beginning of the line.
19 measurement: # Hard-coded tag. 20 measurement: # Hard-coded tag.
20 \s+(\S+) # Match measurement spec. 21 \s+(.+) # Match measurement spec.
21 \s+(\S+) # Match measurement result. 22 \s+([0-9]+(.[0-9]+)?) # Match measurement result.
22 $ # End of the line. 23 $ # End of the line.
23 """ 24 """
24 25
25 _MEASUREMENT_REGEX = re.compile(_MEASUREMENT_RESULT_FORMAT, re.VERBOSE) 26 _MEASUREMENT_REGEX = re.compile(_MEASUREMENT_RESULT_FORMAT, re.VERBOSE)
26 27
27 28
28 def _parse_measurement_results(output): 29 def _parse_measurement_results(output):
29 """Parses the measurement results present in the benchmark output and returns 30 """Parses the measurement results present in the benchmark output and returns
30 the dictionary of correctly recognized and parsed results. 31 the dictionary of correctly recognized and parsed results.
31 """ 32 """
32 measurement_results = {} 33 measurement_results = {}
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 else: 79 else:
79 benchmark_args.append('--trace-output=' + output_file) 80 benchmark_args.append('--trace-output=' + output_file)
80 81
81 for measurement in measurements: 82 for measurement in measurements:
82 benchmark_args.append(measurement['spec']) 83 benchmark_args.append(measurement['spec'])
83 84
84 shell_args = list(shell_args) 85 shell_args = list(shell_args)
85 shell_args.append(_BENCHMARK_APP) 86 shell_args.append(_BENCHMARK_APP)
86 shell_args.append('--force-offline-by-default') 87 shell_args.append('--force-offline-by-default')
87 shell_args.append('--args-for=%s %s' % (_BENCHMARK_APP, 88 shell_args.append('--args-for=%s %s' % (_BENCHMARK_APP,
88 ' '.join(benchmark_args))) 89 ' '.join(map(pipes.quote, benchmark_args))))
89 90
90 if verbose: 91 if verbose:
91 print 'shell arguments: ' + str(shell_args) 92 print 'shell arguments: ' + str(shell_args)
92 return_code, output, did_time_out = shell.run_and_get_output( 93 return_code, output, did_time_out = shell.run_and_get_output(
93 shell_args, timeout=timeout) 94 shell_args, timeout=timeout)
94 95
95 if did_time_out: 96 if did_time_out:
96 return Outcome(False, 'timed out', output) 97 return Outcome(False, 'timed out', output)
97 if return_code: 98 if return_code:
98 return Outcome(False, 'return code: ' + str(return_code), output) 99 return Outcome(False, 'return code: ' + str(return_code), output)
99 100
100 # Pull the trace file even if some measurements are missing, as it can be 101 # Pull the trace file even if some measurements are missing, as it can be
101 # useful in debugging. 102 # useful in debugging.
102 if device_output_file: 103 if device_output_file:
103 shell.pull_file(device_output_file, output_file, remove_original=True) 104 shell.pull_file(device_output_file, output_file, remove_original=True)
104 105
105 outcome = Outcome(True, None, output) 106 outcome = Outcome(True, None, output)
106 parsed_results = _parse_measurement_results(output) 107 parsed_results = _parse_measurement_results(output)
107 for measurement in measurements: 108 for measurement in measurements:
108 spec = measurement['spec'] 109 spec = measurement['spec']
109 if spec in parsed_results: 110 if spec in parsed_results:
110 outcome.results[spec] = parsed_results[spec] 111 outcome.results[spec] = parsed_results[spec]
111 else: 112 else:
112 outcome.some_measurements_failed = True 113 outcome.some_measurements_failed = True
113 return outcome 114 return outcome
OLDNEW
« no previous file with comments | « apps/benchmark/run_args.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698