OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Apple's Speedometer performance benchmark. | 5 """Apple's Speedometer performance benchmark. |
6 | 6 |
7 Speedometer measures simulated user interactions in web applications. | 7 Speedometer measures simulated user interactions in web applications. |
8 | 8 |
9 The current benchmark uses TodoMVC to simulate user actions for adding, | 9 The current benchmark uses TodoMVC to simulate user actions for adding, |
10 completing, and removing to-do items. Speedometer repeats the same actions using | 10 completing, and removing to-do items. Speedometer repeats the same actions using |
11 DOM APIs - a core set of web platform APIs used extensively in web applications- | 11 DOM APIs - a core set of web platform APIs used extensively in web applications- |
12 as well as six popular JavaScript frameworks: Ember.js, Backbone.js, jQuery, | 12 as well as six popular JavaScript frameworks: Ember.js, Backbone.js, jQuery, |
13 AngularJS, React, and Flight. Many of these frameworks are used on the most | 13 AngularJS, React, and Flight. Many of these frameworks are used on the most |
14 popular websites in the world, such as Facebook and Twitter. The performance of | 14 popular websites in the world, such as Facebook and Twitter. The performance of |
15 these types of operations depends on the speed of the DOM APIs, the JavaScript | 15 these types of operations depends on the speed of the DOM APIs, the JavaScript |
16 engine, CSS style resolution, layout, and other technologies. | 16 engine, CSS style resolution, layout, and other technologies. |
17 """ | 17 """ |
18 | 18 |
19 import os | 19 import os |
20 | 20 |
| 21 from metrics import keychain_metric |
21 from telemetry import benchmark | 22 from telemetry import benchmark |
22 from telemetry.page import page_set | 23 from telemetry.page import page_set |
23 from telemetry.page import page_test | 24 from telemetry.page import page_test |
24 from telemetry.value import list_of_scalar_values | 25 from telemetry.value import list_of_scalar_values |
25 | 26 |
26 | 27 |
27 class SpeedometerMeasurement(page_test.PageTest): | 28 class SpeedometerMeasurement(page_test.PageTest): |
28 enabled_suites = [ | 29 enabled_suites = [ |
29 'VanillaJS-TodoMVC', | 30 'VanillaJS-TodoMVC', |
30 'EmberJS-TodoMVC', | 31 'EmberJS-TodoMVC', |
31 'BackboneJS-TodoMVC', | 32 'BackboneJS-TodoMVC', |
32 'jQuery-TodoMVC', | 33 'jQuery-TodoMVC', |
33 'AngularJS-TodoMVC', | 34 'AngularJS-TodoMVC', |
34 'React-TodoMVC', | 35 'React-TodoMVC', |
35 'FlightJS-TodoMVC' | 36 'FlightJS-TodoMVC' |
36 ] | 37 ] |
37 | 38 |
| 39 def CustomizeBrowserOptions(self, options): |
| 40 if keychain_metric.KeychainMetric.ShouldCollectKeychainMetrics(): |
| 41 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) |
| 42 |
38 def ValidateAndMeasurePage(self, page, tab, results): | 43 def ValidateAndMeasurePage(self, page, tab, results): |
39 tab.WaitForDocumentReadyStateToBeComplete() | 44 tab.WaitForDocumentReadyStateToBeComplete() |
40 iterationCount = 10 | 45 iterationCount = 10 |
41 # A single iteration on android takes ~75 seconds, the benchmark times out | 46 # A single iteration on android takes ~75 seconds, the benchmark times out |
42 # when running for 10 iterations. | 47 # when running for 10 iterations. |
43 if tab.browser.platform.GetOSName() == 'android': | 48 if tab.browser.platform.GetOSName() == 'android': |
44 iterationCount = 3 | 49 iterationCount = 3 |
45 | 50 |
46 tab.ExecuteJavaScript(""" | 51 tab.ExecuteJavaScript(""" |
47 // Store all the results in the benchmarkClient | 52 // Store all the results in the benchmarkClient |
(...skipping 16 matching lines...) Expand all Loading... |
64 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 69 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
65 page, suite_name, 'ms', | 70 page, suite_name, 'ms', |
66 tab.EvaluateJavaScript(""" | 71 tab.EvaluateJavaScript(""" |
67 var suite_times = []; | 72 var suite_times = []; |
68 for(var i = 0; i < benchmarkClient.iterationCount; i++) { | 73 for(var i = 0; i < benchmarkClient.iterationCount; i++) { |
69 suite_times.push( | 74 suite_times.push( |
70 benchmarkClient._measuredValues[i].tests['%s'].total); | 75 benchmarkClient._measuredValues[i].tests['%s'].total); |
71 }; | 76 }; |
72 suite_times; | 77 suite_times; |
73 """ % suite_name), important=False)) | 78 """ % suite_name), important=False)) |
| 79 if keychain_metric.KeychainMetric.ShouldCollectKeychainMetrics(): |
| 80 keychain_metric.KeychainMetric().AddResults(tab, results) |
74 | 81 |
75 class Speedometer(benchmark.Benchmark): | 82 class Speedometer(benchmark.Benchmark): |
76 test = SpeedometerMeasurement | 83 test = SpeedometerMeasurement |
77 | 84 |
78 def CreatePageSet(self, options): | 85 def CreatePageSet(self, options): |
79 ps = page_set.PageSet( | 86 ps = page_set.PageSet( |
80 file_path=os.path.abspath(__file__), | 87 file_path=os.path.abspath(__file__), |
81 archive_data_file='../page_sets/data/speedometer.json', | 88 archive_data_file='../page_sets/data/speedometer.json', |
82 make_javascript_deterministic=False, | 89 make_javascript_deterministic=False, |
83 bucket=page_set.PUBLIC_BUCKET) | 90 bucket=page_set.PUBLIC_BUCKET) |
84 ps.AddPageWithDefaultRunNavigate('http://browserbench.org/Speedometer/') | 91 ps.AddPageWithDefaultRunNavigate('http://browserbench.org/Speedometer/') |
85 return ps | 92 return ps |
OLD | NEW |