| 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 import os | 17 import os |
| 18 | 18 |
| 19 from metrics import statistics | 19 from metrics import statistics |
| 20 from telemetry import test | 20 from telemetry import test |
| 21 from telemetry.page import page_measurement | 21 from telemetry.page import page_measurement |
| 22 from telemetry.page import page_set | 22 from telemetry.page import page_set |
| 23 from telemetry.value import merge_values | 23 from telemetry.value import merge_values |
| 24 | 24 |
| 25 class _PeaceKeeperMeasurement(page_measurement.PageMeasurement): | 25 class PeaceKeeperMeasurement(page_measurement.PageMeasurement): |
| 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) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 61 def DidRunTest(self, browser, results): | 61 def DidRunTest(self, browser, results): |
| 62 # Calculate geometric mean as the total for the combined tests. | 62 # Calculate geometric mean as the total for the combined tests. |
| 63 combined = merge_values.MergeLikeValuesFromDifferentPages( | 63 combined = merge_values.MergeLikeValuesFromDifferentPages( |
| 64 results.all_page_specific_values, | 64 results.all_page_specific_values, |
| 65 group_by_name_suffix=True) | 65 group_by_name_suffix=True) |
| 66 combined_score = [x for x in combined if x.name == 'Score'][0] | 66 combined_score = [x for x in combined if x.name == 'Score'][0] |
| 67 total = statistics.GeometricMean(combined_score.values) | 67 total = statistics.GeometricMean(combined_score.values) |
| 68 results.AddSummary('Score', 'score', total, 'Total') | 68 results.AddSummary('Score', 'score', total, 'Total') |
| 69 | 69 |
| 70 | 70 |
| 71 class _PeaceKeeperBenchmark(test.Test): | 71 class PeaceKeeperBenchmark(test.Test): |
| 72 """A base class for Peackeeper benchmarks.""" | 72 """A base class for Peackeeper benchmarks.""" |
| 73 test = _PeaceKeeperMeasurement | 73 test = PeaceKeeperMeasurement |
| 74 | 74 |
| 75 def CreatePageSet(self, options): | 75 def CreatePageSet(self, options): |
| 76 """Makes a PageSet for PeaceKeeper benchmarks.""" | 76 """Makes a PageSet for PeaceKeeper benchmarks.""" |
| 77 # Subclasses are expected to define a class member called query_param. | 77 # Subclasses are expected to define a class member called query_param. |
| 78 if not hasattr(self, 'test_param'): | 78 if not hasattr(self, 'test_param'): |
| 79 raise NotImplementedError('test_param not in PeaceKeeper benchmark.') | 79 raise NotImplementedError('test_param not in PeaceKeeper benchmark.') |
| 80 | 80 |
| 81 # The docstring of benchmark classes may also be used as a description | 81 # The docstring of benchmark classes may also be used as a description |
| 82 # when 'run_benchmarks list' is run. | 82 # when 'run_benchmarks list' is run. |
| 83 description = self.__doc__ or 'PeaceKeeper Benchmark' | 83 description = self.__doc__ or 'PeaceKeeper Benchmark' |
| 84 test_urls = [] | 84 test_urls = [] |
| 85 for test_name in self.test_param: | 85 for test_name in self.test_param: |
| 86 test_urls.append( | 86 test_urls.append( |
| 87 {"url": ("http://peacekeeper.futuremark.com/run.action?debug=true&" | 87 {"url": ("http://peacekeeper.futuremark.com/run.action?debug=true&" |
| 88 "repeat=false&forceSuiteName=%s&forceTestName=%s") % | 88 "repeat=false&forceSuiteName=%s&forceTestName=%s") % |
| 89 (self.tag, test_name) | 89 (self.tag, test_name) |
| 90 }) | 90 }) |
| 91 | 91 |
| 92 page_set_dict = { | 92 page_set_dict = { |
| 93 'description': description, | 93 'description': description, |
| 94 'archive_data_file': '../page_sets/data/peacekeeper_%s.json' % self.tag, | 94 'archive_data_file': '../page_sets/data/peacekeeper_%s.json' % self.tag, |
| 95 'make_javascript_deterministic': False, | 95 'make_javascript_deterministic': False, |
| 96 'pages': test_urls, | 96 'pages': test_urls, |
| 97 } | 97 } |
| 98 return page_set.PageSet.FromDict(page_set_dict, os.path.abspath(__file__)) | 98 return page_set.PageSet.FromDict(page_set_dict, os.path.abspath(__file__)) |
| 99 | 99 |
| 100 | 100 |
| 101 class PeaceKeeperRender(_PeaceKeeperBenchmark): | 101 class PeaceKeeperRender(PeaceKeeperBenchmark): |
| 102 """PeaceKeeper rendering benchmark suite. | 102 """PeaceKeeper rendering benchmark suite. |
| 103 | 103 |
| 104 These tests measure your browser's ability to render and modify specific | 104 These tests measure your browser's ability to render and modify specific |
| 105 elements used in typical web pages. Rendering tests manipulate the DOM tree in | 105 elements used in typical web pages. Rendering tests manipulate the DOM tree in |
| 106 real-time. The tests measure display updating speed (frames per seconds). | 106 real-time. The tests measure display updating speed (frames per seconds). |
| 107 """ | 107 """ |
| 108 tag = 'render' | 108 tag = 'render' |
| 109 test_param = ['renderGrid01', | 109 test_param = ['renderGrid01', |
| 110 'renderGrid02', | 110 'renderGrid02', |
| 111 'renderGrid03', | 111 'renderGrid03', |
| 112 'renderPhysics' | 112 'renderPhysics' |
| 113 ] | 113 ] |
| 114 | 114 |
| 115 | 115 |
| 116 class PeaceKeeperData(_PeaceKeeperBenchmark): | 116 class PeaceKeeperData(PeaceKeeperBenchmark): |
| 117 """PeaceKeeper Data operations benchmark suite. | 117 """PeaceKeeper Data operations benchmark suite. |
| 118 | 118 |
| 119 These tests measure your browser's ability to add, remove and modify data | 119 These tests measure your browser's ability to add, remove and modify data |
| 120 stored in an array. The Data suite consists of two tests: | 120 stored in an array. The Data suite consists of two tests: |
| 121 1. arrayCombined: This test uses all features of the JavaScript Array object. | 121 1. arrayCombined: This test uses all features of the JavaScript Array object. |
| 122 This is a technical test that is not based on profiled data. | 122 This is a technical test that is not based on profiled data. |
| 123 The source data are different sized arrays of numbers. | 123 The source data are different sized arrays of numbers. |
| 124 2. arrayWeighted: This test is similar to 'arrayCombined', but the load is | 124 2. arrayWeighted: This test is similar to 'arrayCombined', but the load is |
| 125 balanced based on profiled data. The source data is a list of all the | 125 balanced based on profiled data. The source data is a list of all the |
| 126 countries in the world. | 126 countries in the world. |
| 127 """ | 127 """ |
| 128 | 128 |
| 129 tag = 'array' | 129 tag = 'array' |
| 130 test_param = ['arrayCombined01', | 130 test_param = ['arrayCombined01', |
| 131 'arrayWeighted' | 131 'arrayWeighted' |
| 132 ] | 132 ] |
| 133 | 133 |
| 134 | 134 |
| 135 class PeaceKeeperDom(_PeaceKeeperBenchmark): | 135 class PeaceKeeperDom(PeaceKeeperBenchmark): |
| 136 """PeaceKeeper DOM operations benchmark suite. | 136 """PeaceKeeper DOM operations benchmark suite. |
| 137 | 137 |
| 138 These tests emulate the methods used to create typical dynamic webpages. | 138 These tests emulate the methods used to create typical dynamic webpages. |
| 139 The DOM tests are based on development experience and the capabilities of the | 139 The DOM tests are based on development experience and the capabilities of the |
| 140 jQuery framework. | 140 jQuery framework. |
| 141 1. domGetElements: This test uses native DOM methods getElementById and | 141 1. domGetElements: This test uses native DOM methods getElementById and |
| 142 getElementsByName. The elements are not modified. | 142 getElementsByName. The elements are not modified. |
| 143 2. domDynamicCreationCreateElement: A common use of DOM is to dynamically | 143 2. domDynamicCreationCreateElement: A common use of DOM is to dynamically |
| 144 create content with JavaScript, this test measures creating objects | 144 create content with JavaScript, this test measures creating objects |
| 145 individually and then appending them to DOM. | 145 individually and then appending them to DOM. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 165 'domDynamicCreationInnerHTML', | 165 'domDynamicCreationInnerHTML', |
| 166 'domJQueryAttributeFilters', | 166 'domJQueryAttributeFilters', |
| 167 'domJQueryBasicFilters', | 167 'domJQueryBasicFilters', |
| 168 'domJQueryBasics', | 168 'domJQueryBasics', |
| 169 'domJQueryContentFilters', | 169 'domJQueryContentFilters', |
| 170 'domJQueryHierarchy', | 170 'domJQueryHierarchy', |
| 171 'domQueryselector' | 171 'domQueryselector' |
| 172 ] | 172 ] |
| 173 | 173 |
| 174 | 174 |
| 175 class PeaceKeeperTextParsing(_PeaceKeeperBenchmark): | 175 class PeaceKeeperTextParsing(PeaceKeeperBenchmark): |
| 176 """PeaceKeeper Text Parsing benchmark suite. | 176 """PeaceKeeper Text Parsing benchmark suite. |
| 177 | 177 |
| 178 These tests measure your browser's performance in typical text manipulations | 178 These tests measure your browser's performance in typical text manipulations |
| 179 such as using a profanity filter for chats, browser detection and form | 179 such as using a profanity filter for chats, browser detection and form |
| 180 validation. | 180 validation. |
| 181 1. stringChat: This test removes swearing from artificial chat messages. | 181 1. stringChat: This test removes swearing from artificial chat messages. |
| 182 Test measures looping and string replace-method. | 182 Test measures looping and string replace-method. |
| 183 2. stringDetectBrowser: This test uses string indexOf-method to detect browser | 183 2. stringDetectBrowser: This test uses string indexOf-method to detect browser |
| 184 and operating system. | 184 and operating system. |
| 185 3. stringFilter: This test filters a list of movies with a given keyword. | 185 3. stringFilter: This test filters a list of movies with a given keyword. |
| 186 The behaviour is known as filtering select or continuous filter. It's used | 186 The behaviour is known as filtering select or continuous filter. It's used |
| 187 to give real time suggestions while a user is filling input fields. | 187 to give real time suggestions while a user is filling input fields. |
| 188 The test uses simple regular expressions. | 188 The test uses simple regular expressions. |
| 189 4. stringValidateForm: This test uses complex regular expressions to validate | 189 4. stringValidateForm: This test uses complex regular expressions to validate |
| 190 user input. | 190 user input. |
| 191 5. stringWeighted: This is an artificial test. Methods used and their | 191 5. stringWeighted: This is an artificial test. Methods used and their |
| 192 intensities are chosen based on profiled data. | 192 intensities are chosen based on profiled data. |
| 193 """ | 193 """ |
| 194 | 194 |
| 195 tag = 'string' | 195 tag = 'string' |
| 196 test_param = ['stringChat', | 196 test_param = ['stringChat', |
| 197 'stringDetectBrowser', | 197 'stringDetectBrowser', |
| 198 'stringFilter', | 198 'stringFilter', |
| 199 'stringWeighted', | 199 'stringWeighted', |
| 200 'stringValidateForm' | 200 'stringValidateForm' |
| 201 ] | 201 ] |
| 202 | 202 |
| 203 | 203 |
| 204 class PeaceKeeperHTML5Canvas(_PeaceKeeperBenchmark): | 204 class PeaceKeeperHTML5Canvas(PeaceKeeperBenchmark): |
| 205 """PeaceKeeper HTML5 Canvas benchmark suite. | 205 """PeaceKeeper HTML5 Canvas benchmark suite. |
| 206 | 206 |
| 207 These tests use HTML5 Canvas, which is a web technology for drawing and | 207 These tests use HTML5 Canvas, which is a web technology for drawing and |
| 208 manipulating graphics without external plug-ins. | 208 manipulating graphics without external plug-ins. |
| 209 1. experimentalRipple01: Simulates a 'water ripple' effect by using HTML 5 | 209 1. experimentalRipple01: Simulates a 'water ripple' effect by using HTML 5 |
| 210 Canvas. It measures the browser's ability to draw individual pixels. | 210 Canvas. It measures the browser's ability to draw individual pixels. |
| 211 2. experimentalRipple02: Same test as 'experimentalRipple01', but with a | 211 2. experimentalRipple02: Same test as 'experimentalRipple01', but with a |
| 212 larger canvas and thus a heavier workload. | 212 larger canvas and thus a heavier workload. |
| 213 """ | 213 """ |
| 214 | 214 |
| 215 tag = 'experimental' | 215 tag = 'experimental' |
| 216 test_param = ['experimentalRipple01', | 216 test_param = ['experimentalRipple01', |
| 217 'experimentalRipple02' | 217 'experimentalRipple02' |
| 218 ] | 218 ] |
| 219 | 219 |
| 220 | 220 |
| 221 class PeaceKeeperHTML5Capabilities(_PeaceKeeperBenchmark): | 221 class PeaceKeeperHTML5Capabilities(PeaceKeeperBenchmark): |
| 222 """PeaceKeeper HTML5 Capabilities benchmark suite. | 222 """PeaceKeeper HTML5 Capabilities benchmark suite. |
| 223 | 223 |
| 224 These tests checks browser HTML5 capabilities support for WebGL, Video | 224 These tests checks browser HTML5 capabilities support for WebGL, Video |
| 225 foramts, simple 2D sprite based games and web worker. | 225 foramts, simple 2D sprite based games and web worker. |
| 226 This benchmark only tests HTML5 capability and thus is not calculate into the | 226 This benchmark only tests HTML5 capability and thus is not calculate into the |
| 227 overall score. | 227 overall score. |
| 228 1. HTML5 - WebGL: WebGL allows full blown 3D graphics to be rendered in a | 228 1. HTML5 - WebGL: WebGL allows full blown 3D graphics to be rendered in a |
| 229 browser without the need for any external plug-ins. | 229 browser without the need for any external plug-ins. |
| 230 a) webglSphere | 230 a) webglSphere |
| 231 2. HTML5 - Video: hese tests find out which HTML5 video formats are supposed | 231 2. HTML5 - Video: hese tests find out which HTML5 video formats are supposed |
| (...skipping 16 matching lines...) Expand all Loading... |
| 248 tag = 'html5' | 248 tag = 'html5' |
| 249 test_param = ['webglSphere', | 249 test_param = ['webglSphere', |
| 250 'gamingSpitfire', | 250 'gamingSpitfire', |
| 251 'videoCodecH264', | 251 'videoCodecH264', |
| 252 'videoCodecTheora', | 252 'videoCodecTheora', |
| 253 'videoCodecWebM', | 253 'videoCodecWebM', |
| 254 'videoPosterSupport', | 254 'videoPosterSupport', |
| 255 'workerContrast01', | 255 'workerContrast01', |
| 256 'workerContrast02' | 256 'workerContrast02' |
| 257 ] | 257 ] |
| OLD | NEW |