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

Side by Side Diff: mojo/devtools/common/mojo_benchmark

Issue 1345753002: Teach `mojo_benchmark` to clear network service disk cache. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runner for Mojo application benchmarks.""" 6 """Runner for Mojo application benchmarks."""
7 7
8 import argparse 8 import argparse
9 import logging 9 import logging
10 import sys 10 import sys
(...skipping 26 matching lines...) Expand all
37 37
38 |benchmark_list_file| may reference the |target_os| global that will be any of 38 |benchmark_list_file| may reference the |target_os| global that will be any of
39 ['android', 'linux'], indicating the system on which the benchmarks are to be 39 ['android', 'linux'], indicating the system on which the benchmarks are to be
40 run. 40 run.
41 """ 41 """
42 42
43 _logger = logging.getLogger() 43 _logger = logging.getLogger()
44 44
45 _BENCHMARK_APP = 'https://core.mojoapps.io/benchmark.mojo' 45 _BENCHMARK_APP = 'https://core.mojoapps.io/benchmark.mojo'
46 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache' 46 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache'
47 _NETWORK_SERVICE_URL = 'mojo:network_service'
47 48
48 # Additional time in seconds allocated per shell run to accommodate start-up. 49 # Additional time in seconds allocated per shell run to accommodate start-up.
49 # The shell should terminate before hitting this time out, it is an error if it 50 # The shell should terminate before hitting this time out, it is an error if it
50 # doesn't. 51 # doesn't.
51 _EXTRA_TIMEOUT = 20 52 _EXTRA_TIMEOUT = 20
52 53
53 54
54 def _run_benchmark(shell, shell_args, name, app, duration_seconds, measurements, 55 def _run_benchmark(shell, shell_args, name, app, duration_seconds, measurements,
55 cold_start, verbose): 56 cold_start, verbose):
56 """Runs `benchmark.mojo` in shell with correct arguments, parses and 57 """Runs `benchmark.mojo` in shell with correct arguments, parses and
57 presents the benchmark results. 58 presents the benchmark results.
58 """ 59 """
59 timeout = duration_seconds + _EXTRA_TIMEOUT 60 timeout = duration_seconds + _EXTRA_TIMEOUT
60 benchmark_args = [] 61 benchmark_args = []
61 benchmark_args.append('--app=' + app) 62 benchmark_args.append('--app=' + app)
62 benchmark_args.append('--duration=' + str(duration_seconds)) 63 benchmark_args.append('--duration=' + str(duration_seconds))
63 for measurement in measurements: 64 for measurement in measurements:
64 benchmark_args.append(measurement) 65 benchmark_args.append(measurement)
65 66
66 shell_args = list(shell_args) 67 shell_args = list(shell_args)
67 shell_args.append(_BENCHMARK_APP) 68 shell_args.append(_BENCHMARK_APP)
68 shell_args.append('--args-for=%s %s' % (_BENCHMARK_APP, 69 shell_args.append('--args-for=%s %s' % (_BENCHMARK_APP,
69 ' '.join(benchmark_args))) 70 ' '.join(benchmark_args)))
70 71
71 if cold_start: 72 if cold_start:
72 shell_args.append('--args-for=%s %s' % (_CACHE_SERVICE_URL, '--clear')) 73 shell_args.append('--args-for=%s %s' % (_CACHE_SERVICE_URL, '--clear'))
74 shell_args.append('--args-for=%s %s' % (_NETWORK_SERVICE_URL, '--clear'))
73 75
74 if verbose: 76 if verbose:
75 print 'shell arguments: ' + str(shell_args) 77 print 'shell arguments: ' + str(shell_args)
76 print '[ %s ] %s' % (name, 'cold start' if cold_start else 'warm start') 78 print '[ %s ] %s' % (name, 'cold start' if cold_start else 'warm start')
77 return_code, output, did_time_out = shell.run_and_get_output( 79 return_code, output, did_time_out = shell.run_and_get_output(
78 shell_args, timeout=timeout) 80 shell_args, timeout=timeout)
79 output_lines = [line.strip() for line in output.split('\n')] 81 output_lines = [line.strip() for line in output.split('\n')]
80 82
81 if return_code or did_time_out or 'benchmark succeeded' not in output_lines: 83 if return_code or did_time_out or 'benchmark succeeded' not in output_lines:
82 print 'timed out' if did_time_out else 'failed' 84 print 'timed out' if did_time_out else 'failed'
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 measurements = benchmark_spec['measurements'] 128 measurements = benchmark_spec['measurements']
127 _run_benchmark(shell, shell_args, name, app, duration, measurements, 129 _run_benchmark(shell, shell_args, name, app, duration, measurements,
128 cold_start=True, verbose=script_args.verbose) 130 cold_start=True, verbose=script_args.verbose)
129 _run_benchmark(shell, shell_args, name, app, duration, measurements, 131 _run_benchmark(shell, shell_args, name, app, duration, measurements,
130 cold_start=False, verbose=script_args.verbose) 132 cold_start=False, verbose=script_args.verbose)
131 133
132 return 0 if succeeded else 1 134 return 0 if succeeded else 1
133 135
134 if __name__ == '__main__': 136 if __name__ == '__main__':
135 sys.exit(main()) 137 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698