| 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 | 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; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 | 53 |
| 54 def MeasurePage(self, _, tab, results): | 54 def MeasurePage(self, _, 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.Add('Score', 'score', int(result['score']), result['test'], | 58 results.Add('Score', 'score', int(result['score']), result['test'], |
| 59 'unimportant') | 59 'unimportant') |
| 60 | 60 |
| 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 scores = [] | 63 combined = merge_values.MergeLikeValuesFromDifferentPages( |
| 64 for result in results.page_results: | 64 results.all_page_specific_values, |
| 65 scores.append(result['Score'].output_value) | 65 group_by_name_suffix=True) |
| 66 total = statistics.GeometricMean(scores) | 66 combined_score = [x for x in combined if x.name == 'Score'][0] |
| 67 total = statistics.GeometricMean(combined_score.values) |
| 67 results.AddSummary('Score', 'score', total, 'Total') | 68 results.AddSummary('Score', 'score', total, 'Total') |
| 68 | 69 |
| 69 | 70 |
| 70 class PeaceKeeperBenchmark(test.Test): | 71 class PeaceKeeperBenchmark(test.Test): |
| 71 """A base class for Peackeeper benchmarks.""" | 72 """A base class for Peackeeper benchmarks.""" |
| 72 test = PeaceKeeperMeasurement | 73 test = PeaceKeeperMeasurement |
| 73 | 74 |
| 74 def CreatePageSet(self, options): | 75 def CreatePageSet(self, options): |
| 75 """Makes a PageSet for PeaceKeeper benchmarks.""" | 76 """Makes a PageSet for PeaceKeeper benchmarks.""" |
| 76 # Subclasses are expected to define a class member called query_param. | 77 # Subclasses are expected to define a class member called query_param. |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 tag = 'html5' | 248 tag = 'html5' |
| 248 test_param = ['webglSphere', | 249 test_param = ['webglSphere', |
| 249 'gamingSpitfire', | 250 'gamingSpitfire', |
| 250 'videoCodecH264', | 251 'videoCodecH264', |
| 251 'videoCodecTheora', | 252 'videoCodecTheora', |
| 252 'videoCodecWebM', | 253 'videoCodecWebM', |
| 253 'videoPosterSupport', | 254 'videoPosterSupport', |
| 254 'workerContrast01', | 255 'workerContrast01', |
| 255 'workerContrast02' | 256 'workerContrast02' |
| 256 ] | 257 ] |
| 257 | |
| OLD | NEW |