| 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 measurements import PageTestMeasurement |
| 17 from telemetry import benchmark | 18 from telemetry import benchmark |
| 18 from telemetry.page import page_set | 19 from telemetry.page import page_set |
| 19 from telemetry.page import page_test | |
| 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 |
| 25 class _PeaceKeeperMeasurement(page_test.PageTest): | 25 class _PeaceKeeperMeasurement(PageTestMeasurement): |
| 26 | 26 |
| 27 def WillNavigateToPage(self, page, tab): | 27 def WillNavigateToPage(self, page, tab): |
| 28 page.script_to_evaluate_on_commit = """ | 28 page.script_to_evaluate_on_commit = """ |
| 29 var __results = {}; | 29 var __results = {}; |
| 30 var _done = false; | 30 var _done = false; |
| 31 var __real_log = window.console.log; | 31 var __real_log = window.console.log; |
| 32 var test_frame = null; | 32 var test_frame = null; |
| 33 var benchmark = null; | 33 var benchmark = null; |
| 34 window.console.log = function(msg) { | 34 window.console.log = function(msg) { |
| 35 if (typeof(msg) == "string" && (msg.indexOf("benchmark")) == 0) { | 35 if (typeof(msg) == "string" && (msg.indexOf("benchmark")) == 0) { |
| 36 test_frame = document.getElementById("testFrame"); | 36 test_frame = document.getElementById("testFrame"); |
| 37 benchmark = test_frame.contentWindow.benchmark; | 37 benchmark = test_frame.contentWindow.benchmark; |
| 38 test_frame.contentWindow.onbeforeunload = {}; | 38 test_frame.contentWindow.onbeforeunload = {}; |
| 39 if ((msg.indexOf("Submit ok.")) != -1) { | 39 if ((msg.indexOf("Submit ok.")) != -1) { |
| 40 _done = true; | 40 _done = true; |
| 41 __results["test"] = benchmark.testObjectName; | 41 __results["test"] = benchmark.testObjectName; |
| 42 __results["score"] = benchmark.test.result; | 42 __results["score"] = benchmark.test.result; |
| 43 if (typeof(benchmark.test.unit) != "undefined") { | 43 if (typeof(benchmark.test.unit) != "undefined") { |
| 44 __results["unit"] = benchmark.test.unit; | 44 __results["unit"] = benchmark.test.unit; |
| 45 } else { | 45 } else { |
| 46 __results["unit"] = benchmark.test.isFps ? "fps" : "ops"; | 46 __results["unit"] = benchmark.test.isFps ? "fps" : "ops"; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 __real_log.apply(this, [msg]); | 50 __real_log.apply(this, [msg]); |
| 51 } | 51 } |
| 52 """ | 52 """ |
| 53 | 53 |
| 54 def ValidateAndMeasurePage(self, _, tab, results): | 54 def ValidateAndMeasurePage(self, page, tab, results): |
| 55 tab.WaitForJavaScriptExpression('_done', 600) | 55 tab.WaitForJavaScriptExpression('_done', 600) |
| 56 result = tab.EvaluateJavaScript('__results') | 56 result = tab.EvaluateJavaScript('__results') |
| 57 | 57 |
| 58 results.AddValue(scalar.ScalarValue( | 58 results.AddValue(scalar.ScalarValue( |
| 59 results.current_page, '%s.Score' % result['test'], 'score', | 59 results.current_page, '%s.Score' % result['test'], 'score', |
| 60 int(result['score'])), important=False) | 60 int(result['score'])), important=False) |
| 61 super(_PeaceKeeperMeasurement, self).ValidateAndMeasurePage( |
| 62 page, tab, results) |
| 61 | 63 |
| 62 def DidRunTest(self, browser, results): | 64 def DidRunTest(self, browser, results): |
| 63 # Calculate geometric mean as the total for the combined tests. | 65 # Calculate geometric mean as the total for the combined tests. |
| 64 combined = merge_values.MergeLikeValuesFromDifferentPages( | 66 combined = merge_values.MergeLikeValuesFromDifferentPages( |
| 65 results.all_page_specific_values, | 67 results.all_page_specific_values, |
| 66 group_by_name_suffix=True) | 68 group_by_name_suffix=True) |
| 67 combined_score = [x for x in combined if x.name == 'Score'][0] | 69 combined_score = [x for x in combined if x.name == 'Score'][0] |
| 68 total = statistics.GeometricMean(combined_score.values) | 70 total = statistics.GeometricMean(combined_score.values) |
| 69 results.AddSummaryValue( | 71 results.AddSummaryValue( |
| 70 scalar.ScalarValue(None, 'Total.Score', 'score', total)) | 72 scalar.ScalarValue(None, 'Total.Score', 'score', total)) |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 tag = 'html5' | 250 tag = 'html5' |
| 249 test_param = ['webglSphere', | 251 test_param = ['webglSphere', |
| 250 'gamingSpitfire', | 252 'gamingSpitfire', |
| 251 'videoCodecH264', | 253 'videoCodecH264', |
| 252 'videoCodecTheora', | 254 'videoCodecTheora', |
| 253 'videoCodecWebM', | 255 'videoCodecWebM', |
| 254 'videoPosterSupport', | 256 'videoPosterSupport', |
| 255 'workerContrast01', | 257 'workerContrast01', |
| 256 'workerContrast02' | 258 'workerContrast02' |
| 257 ] | 259 ] |
| OLD | NEW |