| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Runs spaceport.io's PerfMarks benchmark.""" |
| 6 |
| 5 import logging | 7 import logging |
| 8 import os |
| 6 | 9 |
| 7 from telemetry.core import util | 10 from telemetry.core import util |
| 8 from telemetry.page import page_measurement | 11 from telemetry.page import page_measurement |
| 12 from telemetry.page import page_set |
| 9 | 13 |
| 10 class SpaceportMeasurement(page_measurement.PageMeasurement): | 14 class SpaceportMeasurement(page_measurement.PageMeasurement): |
| 15 def CreatePageSet(self, options): |
| 16 return page_set.PageSet.FromDict({ |
| 17 'pages': [ |
| 18 {'url': |
| 19 'file:///../../../chrome/test/data/third_party/spaceport/index.html'} |
| 20 ] |
| 21 }, os.path.abspath(__file__)) |
| 22 |
| 11 def CustomizeBrowserOptions(self, options): | 23 def CustomizeBrowserOptions(self, options): |
| 12 options.extra_browser_args.extend(['--disable-gpu-vsync']) | 24 options.extra_browser_args.extend(['--disable-gpu-vsync']) |
| 13 | 25 |
| 14 def MeasurePage(self, _, tab, results): | 26 def MeasurePage(self, _, tab, results): |
| 15 util.WaitFor(lambda: tab.EvaluateJavaScript( | 27 util.WaitFor(lambda: tab.EvaluateJavaScript( |
| 16 '!document.getElementById("start-performance-tests").disabled'), 60) | 28 '!document.getElementById("start-performance-tests").disabled'), 60) |
| 17 | 29 |
| 18 tab.ExecuteJavaScript(""" | 30 tab.ExecuteJavaScript(""" |
| 19 window.__results = {}; | 31 window.__results = {}; |
| 20 window.console.log = function(str) { | 32 window.console.log = function(str) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 return num_tests_complete[0] >= num_tests_in_measurement | 51 return num_tests_complete[0] >= num_tests_in_measurement |
| 40 util.WaitFor(_IsDone, 1200, poll_interval=5) | 52 util.WaitFor(_IsDone, 1200, poll_interval=5) |
| 41 | 53 |
| 42 result_dict = eval(tab.EvaluateJavaScript(js_get_results)) | 54 result_dict = eval(tab.EvaluateJavaScript(js_get_results)) |
| 43 for key in result_dict: | 55 for key in result_dict: |
| 44 chart, trace = key.split('.', 1) | 56 chart, trace = key.split('.', 1) |
| 45 results.Add(trace, 'objects (bigger is better)', float(result_dict[key]), | 57 results.Add(trace, 'objects (bigger is better)', float(result_dict[key]), |
| 46 chart_name=chart, data_type='unimportant') | 58 chart_name=chart, data_type='unimportant') |
| 47 results.Add('Score', 'objects (bigger is better)', | 59 results.Add('Score', 'objects (bigger is better)', |
| 48 [float(x) for x in result_dict.values()]) | 60 [float(x) for x in result_dict.values()]) |
| OLD | NEW |