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

Side by Side Diff: sky/tools/test_perf

Issue 710133002: Make Sky's test_perf actually test performance (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « sky/tools/skypy/find_tests.py ('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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 from skypy.find_tests import find_tests
7 from skypy.paths import Paths
8 import argparse
6 import os 9 import os
7 import re 10 import re
8 from skypy.paths import Paths 11 import requests
12 import skypy.configuration as configuration
9 import subprocess 13 import subprocess
10 import requests
11 14
12 15
13 SUPPORTED_MIME_TYPES = [ 16 SUPPORTED_MIME_TYPES = [
14 'text/html', 17 'text/html',
15 'text/sky', 18 'text/sky',
16 'text/plain', 19 'text/plain',
17 ] 20 ]
18 HTTP_PORT = 9999 21 HTTP_PORT = 9999
19 22 URL_ROOT = 'http://localhost:%s/' % HTTP_PORT
20 DASHBOARD_URL = 'https://chromeperf.appspot.com/add_point' 23 DASHBOARD_URL = 'https://chromeperf.appspot.com/add_point'
24 BENCHMARKS_DIR = 'benchmarks'
21 25
22 26
23 def values_from_output(output): 27 def values_from_output(output):
24 # Parse out the raw values from the PerfRunner output: 28 # Parse out the raw values from the PerfRunner output:
25 # values 90, 89, 93 ms 29 # values 90, 89, 93 ms
26 # We'll probably need a fancier parser at some point. 30 # We'll probably need a fancier parser at some point.
27 match = re.search(r'values (.+) ms', output, flags=re.MULTILINE) 31 match = re.search(r'values (.+) ms', output, flags=re.MULTILINE)
28 return map(float, match.group(1).split(', ')) 32 return map(float, match.group(1).split(', '))
29 33
30 34
(...skipping 21 matching lines...) Expand all
52 } 56 }
53 } 57 }
54 } 58 }
55 59
56 60
57 def send_json_to_dashboard(json): 61 def send_json_to_dashboard(json):
58 requests.post(DASHBOARD_URL, params={ 'data': json }) 62 requests.post(DASHBOARD_URL, params={ 'data': json })
59 63
60 64
61 class PerfHarness(object): 65 class PerfHarness(object):
62 def __init__(self): 66 def __init__(self, args):
63 self._sky_server = None 67 self._sky_server = None
64 self.paths = Paths(os.path.join('out', 'Debug')) 68 self.paths = Paths(os.path.join('out', 'Debug'))
69 self.args = args
65 70
66 def _start_server(self): 71 def _start_server(self):
67 return subprocess.Popen([ 72 return subprocess.Popen([
68 os.path.join(self.paths.sky_tools_directory, 'sky_server'), 73 os.path.join(self.paths.sky_tools_directory, 'sky_server'),
69 self.paths.src_root, 74 self.paths.src_root,
70 str(HTTP_PORT), 75 str(HTTP_PORT),
76 '-t', self.args.configuration
71 ]) 77 ])
72 78
73 def _sky_tester_command(self, url): 79 def _sky_tester_command(self, url):
74 content_handlers = ['%s,%s' % (mime_type, 'mojo:sky_viewer') 80 content_handlers = ['%s,%s' % (mime_type, 'mojo:sky_viewer')
75 for mime_type in SUPPORTED_MIME_TYPES] 81 for mime_type in SUPPORTED_MIME_TYPES]
76 return [ 82 return [
77 self.paths.mojo_shell_path, 83 self.paths.mojo_shell_path,
78 '--args-for=mojo:native_viewport_service --use-headless-config --use -osmesa', 84 '--args-for=mojo:native_viewport_service --use-headless-config --use -osmesa',
79 '--args-for=mojo:window_manager %s' % url, 85 '--args-for=mojo:window_manager %s' % url,
80 '--content-handlers=%s' % ','.join(content_handlers), 86 '--content-handlers=%s' % ','.join(content_handlers),
81 '--url-mappings=mojo:window_manager=mojo:sky_tester', 87 '--url-mappings=mojo:window_manager=mojo:sky_tester',
82 'mojo:window_manager', 88 'mojo:window_manager',
83 ] 89 ]
84 90
91 def _url_for_path(self, path):
92 return URL_ROOT + os.path.relpath(path, self.paths.src_root)
93
94 def _run_tests(self, path):
95 url = self._url_for_path(path)
96 output = subprocess.check_output(
97 self._sky_tester_command(url),
98 stderr=subprocess.STDOUT)
99 values = values_from_output(output)
100 print os.path.basename(path), "=>", values
101 # FIXME: Upload JSON blob to results server:
102 # json = create_json_blob(values)
103 # send_json_to_dashboard(json)
85 104
86 def main(self): 105 def main(self):
87 test = 'http://localhost:9999/sky/benchmarks/layout/simple-blocks.sky'
88
89 self._start_server() 106 self._start_server()
90 output = subprocess.check_output(self._sky_tester_command(test)) 107 map(self._run_tests, find_tests(os.path.join(self.paths.sky_root, BENCHM ARKS_DIR)))
91 values = values_from_output(output)
92 json = create_json_blob(values)
93 send_json_to_dashboard(json)
94 108
95 def shutdown(self): 109 def shutdown(self):
96 if self._sky_server: 110 if self._sky_server:
97 self._sky_server.terminate() 111 self._sky_server.terminate()
98 112
99 113
100 if __name__ == '__main__': 114 def main():
101 harness = PerfHarness() 115 parser = argparse.ArgumentParser(description='Sky performance tester')
116 configuration.add_arguments(parser)
117 args = parser.parse_args()
118
119 harness = PerfHarness(args)
102 try: 120 try:
103 harness.main() 121 harness.main()
104 except (KeyboardInterrupt, SystemExit): 122 except (KeyboardInterrupt, SystemExit):
105 pass 123 pass
106 finally: 124 finally:
107 harness.shutdown() 125 harness.shutdown()
126
127
128 if __name__ == '__main__':
129 main()
OLDNEW
« no previous file with comments | « sky/tools/skypy/find_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698