| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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.""" | 5 """Runs spaceport.io's PerfMarks benchmark.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class _SpaceportMeasurement(legacy_page_test.LegacyPageTest): | 53 class _SpaceportMeasurement(legacy_page_test.LegacyPageTest): |
| 54 | 54 |
| 55 def __init__(self): | 55 def __init__(self): |
| 56 super(_SpaceportMeasurement, self).__init__() | 56 super(_SpaceportMeasurement, self).__init__() |
| 57 | 57 |
| 58 def CustomizeBrowserOptions(self, options): | 58 def CustomizeBrowserOptions(self, options): |
| 59 options.AppendExtraBrowserArgs('--disable-gpu-vsync') | 59 options.AppendExtraBrowserArgs('--disable-gpu-vsync') |
| 60 | 60 |
| 61 def ValidateAndMeasurePage(self, page, tab, results): | 61 def ValidateAndMeasurePage(self, page, tab, results): |
| 62 del page # unused | 62 del page # unused |
| 63 tab.WaitForJavaScriptCondition2( | 63 tab.WaitForJavaScriptCondition( |
| 64 '!document.getElementById("start-performance-tests").disabled', | 64 '!document.getElementById("start-performance-tests").disabled', |
| 65 timeout=60) | 65 timeout=60) |
| 66 | 66 |
| 67 tab.ExecuteJavaScript2(""" | 67 tab.ExecuteJavaScript(""" |
| 68 window.__results = {}; | 68 window.__results = {}; |
| 69 window.console.log = function(str) { | 69 window.console.log = function(str) { |
| 70 if (!str) return; | 70 if (!str) return; |
| 71 var key_val = str.split(': '); | 71 var key_val = str.split(': '); |
| 72 if (!key_val.length == 2) return; | 72 if (!key_val.length == 2) return; |
| 73 __results[key_val[0]] = key_val[1]; | 73 __results[key_val[0]] = key_val[1]; |
| 74 }; | 74 }; |
| 75 document.getElementById('start-performance-tests').click(); | 75 document.getElementById('start-performance-tests').click(); |
| 76 """) | 76 """) |
| 77 | 77 |
| 78 num_results = 0 | 78 num_results = 0 |
| 79 num_tests_in_spaceport = 24 | 79 num_tests_in_spaceport = 24 |
| 80 while num_results < num_tests_in_spaceport: | 80 while num_results < num_tests_in_spaceport: |
| 81 tab.WaitForJavaScriptCondition2( | 81 tab.WaitForJavaScriptCondition( |
| 82 'Object.keys(window.__results).length > {{ num_results }}', | 82 'Object.keys(window.__results).length > {{ num_results }}', |
| 83 num_results=num_results, | 83 num_results=num_results, |
| 84 timeout=180) | 84 timeout=180) |
| 85 num_results = tab.EvaluateJavaScript2( | 85 num_results = tab.EvaluateJavaScript( |
| 86 'Object.keys(window.__results).length') | 86 'Object.keys(window.__results).length') |
| 87 logging.info('Completed test %d of %d', | 87 logging.info('Completed test %d of %d', |
| 88 num_results, num_tests_in_spaceport) | 88 num_results, num_tests_in_spaceport) |
| 89 | 89 |
| 90 result_dict = json.loads(tab.EvaluateJavaScript2( | 90 result_dict = json.loads(tab.EvaluateJavaScript( |
| 91 'JSON.stringify(window.__results)')) | 91 'JSON.stringify(window.__results)')) |
| 92 for key in result_dict: | 92 for key in result_dict: |
| 93 chart, trace = key.split('.', 1) | 93 chart, trace = key.split('.', 1) |
| 94 results.AddValue(scalar.ScalarValue( | 94 results.AddValue(scalar.ScalarValue( |
| 95 results.current_page, '%s.%s' % (chart, trace), | 95 results.current_page, '%s.%s' % (chart, trace), |
| 96 'objects (bigger is better)', float(result_dict[key]), | 96 'objects (bigger is better)', float(result_dict[key]), |
| 97 important=False, description=DESCRIPTIONS.get(chart))) | 97 important=False, description=DESCRIPTIONS.get(chart))) |
| 98 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 98 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 99 results.current_page, 'Score', 'objects (bigger is better)', | 99 results.current_page, 'Score', 'objects (bigger is better)', |
| 100 [float(x) for x in result_dict.values()], | 100 [float(x) for x in result_dict.values()], |
| (...skipping 17 matching lines...) Expand all Loading... |
| 118 @classmethod | 118 @classmethod |
| 119 def Name(cls): | 119 def Name(cls): |
| 120 return 'spaceport' | 120 return 'spaceport' |
| 121 | 121 |
| 122 def CreateStorySet(self, options): | 122 def CreateStorySet(self, options): |
| 123 spaceport_dir = os.path.join(path_util.GetChromiumSrcDir(), 'chrome', | 123 spaceport_dir = os.path.join(path_util.GetChromiumSrcDir(), 'chrome', |
| 124 'test', 'data', 'third_party', 'spaceport') | 124 'test', 'data', 'third_party', 'spaceport') |
| 125 ps = story.StorySet(base_dir=spaceport_dir) | 125 ps = story.StorySet(base_dir=spaceport_dir) |
| 126 ps.AddStory(page_module.Page('file://index.html', ps, ps.base_dir)) | 126 ps.AddStory(page_module.Page('file://index.html', ps, ps.base_dir)) |
| 127 return ps | 127 return ps |
| OLD | NEW |