OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (C) 2012 Google Inc. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # Redistribution and use in source and binary forms, with or without | 4 # found in the LICENSE file. |
5 # modification, are permitted provided that the following conditions are | |
6 # met: | |
7 # | |
8 # * Redistributions of source code must retain the above copyright | |
9 # notice, this list of conditions and the following disclaimer. | |
10 # * Redistributions in binary form must reproduce the above | |
11 # copyright notice, this list of conditions and the following disclaimer | |
12 # in the documentation and/or other materials provided with the | |
13 # distribution. | |
14 # * Neither the name of Google Inc. nor the names of its | |
15 # contributors may be used to endorse or promote products derived from | |
16 # this software without specific prior written permission. | |
17 # | |
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | 5 |
30 """Run performance tests.""" | 6 import os |
7 import re | |
8 import skypy.paths as paths | |
9 import subprocess | |
10 import requests | |
31 | 11 |
32 import logging | |
33 import sys | |
34 | 12 |
35 from webkitpy.performance_tests.perftestsrunner import PerfTestsRunner | 13 SUPPORTED_MIME_TYPES = [ |
14 'text/html', | |
15 'text/sky', | |
16 'text/plain', | |
17 ] | |
18 HTTP_PORT = 9999 | |
36 | 19 |
37 if '__main__' == __name__: | 20 DASHBOARD_URL = 'https://chromeperf.appspot.com/add_point' |
38 logging.basicConfig(level=logging.INFO, format="%(message)s") | |
39 | 21 |
40 sys.exit(PerfTestsRunner().run()) | 22 |
23 def sky_tester_command(url): | |
24 content_handlers = ['%s,%s' % (mime_type, 'mojo://sky_viewer/') | |
25 for mime_type in SUPPORTED_MIME_TYPES] | |
26 return [ | |
27 paths.MOJO_SHELL_PATH, | |
28 '--args-for=mojo://native_viewport_service/ --use-headless-config --use- osmesa', | |
29 '--args-for=mojo://window_manager/ %s' % url, | |
30 '--content-handlers=%s' % ','.join(content_handlers), | |
31 '--url-mappings=mojo:window_manager=mojo://sky_tester/', | |
32 'mojo:window_manager', | |
33 ] | |
34 | |
35 | |
36 def start_sky_server(port): | |
37 return subprocess.Popen([ | |
38 os.path.join(paths.SKY_TOOLS_DIRECTORY, 'sky_server'), | |
39 paths.SRC_ROOT, | |
40 str(port), | |
41 ]) | |
42 | |
43 | |
44 def values_from_output(output): | |
45 match = re.search(r'values (.+) ms', output, flags=re.MULTILINE) | |
eseidel
2014/11/05 00:40:44
maybe a constant with some explanation of what you
| |
46 return map(float, match.group(1).split(', ')) | |
47 | |
48 | |
49 def create_json_blob(values): | |
50 revision = subprocess.check_output(["git", "show-ref", "HEAD", "-s"]).strip( ) | |
eseidel
2014/11/05 00:40:44
James just wrote this same code. We're gonna evne
| |
51 return { | |
52 "master": "master.mojo.perf", | |
53 "bot": "sky-release", | |
54 "point_id": 123456, # FIXME: We need to generate a monotonicly increasin g number somehow. | |
55 "versions": { | |
56 "mojo": revision | |
57 }, | |
58 "chart_data": { | |
59 "format_version": "1.0", | |
60 "benchmark_name": "layout.simple-blocks", | |
61 "charts": { | |
62 "warm_times": { | |
63 "traces": { | |
64 "layout.simple-blocks": { | |
65 "type": "list_of_scalar_values", | |
66 "values": values, | |
67 }, | |
68 } | |
69 } | |
70 } | |
71 } | |
72 } | |
73 | |
74 | |
75 def send_json_to_dashboard(json): | |
76 requests.post(DASHBOARD_URL, params={ 'data': json }) | |
77 | |
78 | |
79 class PerfHarness(object): | |
80 def __init__(self): | |
81 self._sky_server = None | |
82 | |
83 def _start_server(self): | |
84 self._sky_server = start_sky_server(HTTP_PORT) | |
85 | |
86 def main(self): | |
87 test = 'http://localhost:9999/sky/benchmarks/layout/simple-blocks.sky' | |
88 | |
89 self._start_server() | |
90 output = subprocess.check_output(sky_tester_command(test)) | |
91 values = values_from_output(output) | |
92 json = create_json_blob(values) | |
93 send_json_to_dashboard(json) | |
94 | |
95 def shutdown(self): | |
96 if self._sky_server: | |
97 self._sky_server.terminate() | |
98 | |
99 | |
100 if __name__ == '__main__': | |
101 harness = PerfHarness() | |
102 try: | |
103 harness.main() | |
104 except (KeyboardInterrupt, SystemExit): | |
105 pass | |
106 finally: | |
107 harness.shutdown() | |
OLD | NEW |