OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """PeaceKeeper benchmark suite. | 5 """PeaceKeeper benchmark suite. |
6 | 6 |
7 Peacekeeper measures browser's performance by testing its JavaScript | 7 Peacekeeper measures browser's performance by testing its JavaScript |
8 functionality. JavaScript is a widely used programming language used in the | 8 functionality. JavaScript is a widely used programming language used in the |
9 creation of modern websites to provide features such as animation, navigation, | 9 creation of modern websites to provide features such as animation, navigation, |
10 forms and other common requirements. By measuring a browser's ability to handle | 10 forms and other common requirements. By measuring a browser's ability to handle |
11 commonly used JavaScript functions Peacekeeper can evaluate its performance. | 11 commonly used JavaScript functions Peacekeeper can evaluate its performance. |
12 Peacekeeper scores are measured in operations per second or rendered frames per | 12 Peacekeeper scores are measured in operations per second or rendered frames per |
13 second depending on the test. Final Score is computed by calculating geometric | 13 second depending on the test. Final Score is computed by calculating geometric |
14 mean of individual tests scores. | 14 mean of individual tests scores. |
15 """ | 15 """ |
16 | 16 |
17 from telemetry import benchmark | 17 from telemetry import benchmark |
18 from telemetry.page import page_measurement | 18 from telemetry.page import page_measurement |
19 from telemetry.page import page_set | 19 from telemetry.page import page_set |
20 from telemetry.util import statistics | 20 from telemetry.util import statistics |
21 from telemetry.value import merge_values | 21 from telemetry.value import merge_values |
22 from telemetry.value import scalar | 22 from telemetry.value import scalar |
23 | 23 |
| 24 |
24 class _PeaceKeeperMeasurement(page_measurement.PageMeasurement): | 25 class _PeaceKeeperMeasurement(page_measurement.PageMeasurement): |
25 | 26 |
26 def WillNavigateToPage(self, page, tab): | 27 def WillNavigateToPage(self, page, tab): |
27 page.script_to_evaluate_on_commit = """ | 28 page.script_to_evaluate_on_commit = """ |
28 var __results = {}; | 29 var __results = {}; |
29 var _done = false; | 30 var _done = false; |
30 var __real_log = window.console.log; | 31 var __real_log = window.console.log; |
31 var test_frame = null; | 32 var test_frame = null; |
32 var benchmark = null; | 33 var benchmark = null; |
33 window.console.log = function(msg) { | 34 window.console.log = function(msg) { |
(...skipping 13 matching lines...) Expand all Loading... |
47 } | 48 } |
48 } | 49 } |
49 __real_log.apply(this, [msg]); | 50 __real_log.apply(this, [msg]); |
50 } | 51 } |
51 """ | 52 """ |
52 | 53 |
53 def MeasurePage(self, _, tab, results): | 54 def MeasurePage(self, _, tab, results): |
54 tab.WaitForJavaScriptExpression('_done', 600) | 55 tab.WaitForJavaScriptExpression('_done', 600) |
55 result = tab.EvaluateJavaScript('__results') | 56 result = tab.EvaluateJavaScript('__results') |
56 | 57 |
57 results.Add('Score', 'score', int(result['score']), result['test'], | 58 results.AddValue(scalar.ScalarValue( |
58 'unimportant') | 59 results.current_page, '%s.Score' % result['test'], 'score', |
| 60 int(result['score'])), important=False) |
59 | 61 |
60 def DidRunTest(self, browser, results): | 62 def DidRunTest(self, browser, results): |
61 # Calculate geometric mean as the total for the combined tests. | 63 # Calculate geometric mean as the total for the combined tests. |
62 combined = merge_values.MergeLikeValuesFromDifferentPages( | 64 combined = merge_values.MergeLikeValuesFromDifferentPages( |
63 results.all_page_specific_values, | 65 results.all_page_specific_values, |
64 group_by_name_suffix=True) | 66 group_by_name_suffix=True) |
65 combined_score = [x for x in combined if x.name == 'Score'][0] | 67 combined_score = [x for x in combined if x.name == 'Score'][0] |
66 total = statistics.GeometricMean(combined_score.values) | 68 total = statistics.GeometricMean(combined_score.values) |
67 results.AddSummaryValue( | 69 results.AddSummaryValue( |
68 scalar.ScalarValue(None, 'Total.Score', 'score', total)) | 70 scalar.ScalarValue(None, 'Total.Score', 'score', total)) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 tag = 'html5' | 248 tag = 'html5' |
247 test_param = ['webglSphere', | 249 test_param = ['webglSphere', |
248 'gamingSpitfire', | 250 'gamingSpitfire', |
249 'videoCodecH264', | 251 'videoCodecH264', |
250 'videoCodecTheora', | 252 'videoCodecTheora', |
251 'videoCodecWebM', | 253 'videoCodecWebM', |
252 'videoPosterSupport', | 254 'videoPosterSupport', |
253 'workerContrast01', | 255 'workerContrast01', |
254 'workerContrast02' | 256 'workerContrast02' |
255 ] | 257 ] |
OLD | NEW |