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 telemetry import benchmark | 21 from telemetry import benchmark |
22 from telemetry.page import page_set | 22 from telemetry.page import page_set |
23 from telemetry.page import page_test | 23 from telemetry.page import page_test |
24 from telemetry.value import list_of_scalar_values | 24 from telemetry.value import list_of_scalar_values |
25 | 25 |
26 | 26 |
27 class SpeedometerMeasurement(page_test.PageTest): | 27 class SpeedometerMeasurement(page_test.PageTest): |
| 28 enabled_suites = [ |
| 29 'VanillaJS-TodoMVC', |
| 30 'EmberJS-TodoMVC', |
| 31 'BackboneJS-TodoMVC', |
| 32 'jQuery-TodoMVC', |
| 33 'AngularJS-TodoMVC', |
| 34 'React-TodoMVC', |
| 35 'FlightJS-TodoMVC' |
| 36 ] |
28 | 37 |
29 def ValidateAndMeasurePage(self, page, tab, results): | 38 def ValidateAndMeasurePage(self, page, tab, results): |
30 tab.WaitForDocumentReadyStateToBeComplete() | 39 tab.WaitForDocumentReadyStateToBeComplete() |
31 tab.ExecuteJavaScript('benchmarkClient.iterationCount = 10; startTest();') | 40 tab.ExecuteJavaScript(""" |
| 41 // Store all the results in the benchmarkClient |
| 42 benchmarkClient._measuredValues = [] |
| 43 benchmarkClient.didRunSuites = function(measuredValues) { |
| 44 benchmarkClient._measuredValues.push(measuredValues); |
| 45 benchmarkClient._timeValues.push(measuredValues.total); |
| 46 }; |
| 47 benchmarkClient.iterationCount = 10; |
| 48 startTest(); |
| 49 """) |
32 tab.WaitForJavaScriptExpression( | 50 tab.WaitForJavaScriptExpression( |
33 'benchmarkClient._finishedTestCount == benchmarkClient.testsCount', 600) | 51 'benchmarkClient._finishedTestCount == benchmarkClient.testsCount', 600) |
34 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 52 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
35 page, 'Total', 'ms', | 53 page, 'Total', 'ms', |
36 tab.EvaluateJavaScript('benchmarkClient._timeValues'))) | 54 tab.EvaluateJavaScript('benchmarkClient._timeValues'), important=True)) |
37 | 55 |
| 56 # Extract the timings for each suite |
| 57 for suite_name in self.enabled_suites: |
| 58 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 59 page, suite_name, 'ms', |
| 60 tab.EvaluateJavaScript(""" |
| 61 var suite_times = []; |
| 62 for(var i = 0; i < benchmarkClient.iterationCount; i++) { |
| 63 suite_times.push( |
| 64 benchmarkClient._measuredValues[i].tests['%s'].total); |
| 65 }; |
| 66 suite_times; |
| 67 """ % suite_name), important=False)) |
38 | 68 |
39 @benchmark.Disabled('android') # Times out | 69 @benchmark.Disabled('android') # Times out |
40 class Speedometer(benchmark.Benchmark): | 70 class Speedometer(benchmark.Benchmark): |
41 test = SpeedometerMeasurement | 71 test = SpeedometerMeasurement |
42 | 72 |
43 def CreatePageSet(self, options): | 73 def CreatePageSet(self, options): |
44 ps = page_set.PageSet( | 74 ps = page_set.PageSet( |
45 file_path=os.path.abspath(__file__), | 75 file_path=os.path.abspath(__file__), |
46 archive_data_file='../page_sets/data/speedometer.json', | 76 archive_data_file='../page_sets/data/speedometer.json', |
47 make_javascript_deterministic=False) | 77 make_javascript_deterministic=False) |
48 ps.AddPageWithDefaultRunNavigate('http://browserbench.org/Speedometer/') | 78 ps.AddPageWithDefaultRunNavigate('http://browserbench.org/Speedometer/') |
49 return ps | 79 return ps |
OLD | NEW |