blob: b9db1494909ebc235782d57217bf3f51b7c47297 [file]
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import re
from skypy.paths import Paths
import subprocess
import requests
SUPPORTED_MIME_TYPES = [
'text/html',
'text/sky',
'text/plain',
]
HTTP_PORT = 9999
DASHBOARD_URL = 'https://chromeperf.appspot.com/add_point'
def values_from_output(output):
# Parse out the raw values from the PerfRunner output:
# values 90, 89, 93 ms
# We'll probably need a fancier parser at some point.
match = re.search(r'values (.+) ms', output, flags=re.MULTILINE)
return map(float, match.group(1).split(', '))
def create_json_blob(values):
revision = subprocess.check_output(["git", "show-ref", "HEAD", "-s"]).strip()
return {
"master": "master.mojo.perf",
"bot": "sky-release",
"point_id": 123456, # FIXME: We need to generate a monotonicly increasing number somehow.
"versions": {
"mojo": revision
},
"chart_data": {
"format_version": "1.0",
"benchmark_name": "layout.simple-blocks",
"charts": {
"warm_times": {
"traces": {
"layout.simple-blocks": {
"type": "list_of_scalar_values",
"values": values,
},
}
}
}
}
}
def send_json_to_dashboard(json):
requests.post(DASHBOARD_URL, params={ 'data': json })
class PerfHarness(object):
def __init__(self):
self._sky_server = None
self.paths = Paths(os.path.join('out', 'Debug'))
def _start_server(self):
return subprocess.Popen([
os.path.join(self.paths.sky_tools_directory, 'sky_server'),
self.paths.src_root,
str(HTTP_PORT),
])
def _sky_tester_command(self, url):
content_handlers = ['%s,%s' % (mime_type, 'mojo:sky_viewer')
for mime_type in SUPPORTED_MIME_TYPES]
return [
self.paths.mojo_shell_path,
'--args-for=mojo:native_viewport_service --use-headless-config --use-osmesa',
'--args-for=mojo:window_manager %s' % url,
'--content-handlers=%s' % ','.join(content_handlers),
'--url-mappings=mojo:window_manager=mojo:sky_tester',
'mojo:window_manager',
]
def main(self):
test = 'http://localhost:9999/sky/benchmarks/layout/simple-blocks.sky'
self._start_server()
output = subprocess.check_output(self._sky_tester_command(test))
values = values_from_output(output)
json = create_json_blob(values)
send_json_to_dashboard(json)
def shutdown(self):
if self._sky_server:
self._sky_server.terminate()
if __name__ == '__main__':
harness = PerfHarness()
try:
harness.main()
except (KeyboardInterrupt, SystemExit):
pass
finally:
harness.shutdown()