| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 import json | 5 import json |
| 6 import math | 6 import math |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 from telemetry import test | 9 from telemetry import test |
| 10 from telemetry.core import util | 10 from telemetry.core import util |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 # Raise e to that sum over the number of values. | 28 # Raise e to that sum over the number of values. |
| 29 mean = math.pow(math.e, (log_sum / len(new_values))) | 29 mean = math.pow(math.e, (log_sum / len(new_values))) |
| 30 # Return the rounded mean. | 30 # Return the rounded mean. |
| 31 return int(round(mean)) | 31 return int(round(mean)) |
| 32 | 32 |
| 33 | 33 |
| 34 SCORE_UNIT = 'score (bigger is better)' | 34 SCORE_UNIT = 'score (bigger is better)' |
| 35 SCORE_TRACE_NAME = 'score' | 35 SCORE_TRACE_NAME = 'score' |
| 36 | 36 |
| 37 | 37 |
| 38 class DomPerfMeasurement(page_measurement.PageMeasurement): | 38 class _DomPerfMeasurement(page_measurement.PageMeasurement): |
| 39 @property | 39 @property |
| 40 def results_are_the_same_on_every_page(self): | 40 def results_are_the_same_on_every_page(self): |
| 41 return False | 41 return False |
| 42 | 42 |
| 43 def MeasurePage(self, page, tab, results): | 43 def MeasurePage(self, page, tab, results): |
| 44 try: | 44 try: |
| 45 def _IsDone(): | 45 def _IsDone(): |
| 46 return tab.GetCookieByName('__domperf_finished') == '1' | 46 return tab.GetCookieByName('__domperf_finished') == '1' |
| 47 util.WaitFor(_IsDone, 600) | 47 util.WaitFor(_IsDone, 600) |
| 48 | 48 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 total = _GeometricMean(scores) | 63 total = _GeometricMean(scores) |
| 64 results.AddSummary(SCORE_TRACE_NAME, SCORE_UNIT, total, 'Total') | 64 results.AddSummary(SCORE_TRACE_NAME, SCORE_UNIT, total, 'Total') |
| 65 | 65 |
| 66 | 66 |
| 67 class DomPerf(test.Test): | 67 class DomPerf(test.Test): |
| 68 """A suite of JavaScript benchmarks for exercising the browser's DOM. | 68 """A suite of JavaScript benchmarks for exercising the browser's DOM. |
| 69 | 69 |
| 70 The final score is computed as the geometric mean of the individual results. | 70 The final score is computed as the geometric mean of the individual results. |
| 71 Scores are not comparable across benchmark suite versions and higher scores | 71 Scores are not comparable across benchmark suite versions and higher scores |
| 72 means better performance: Bigger is better!""" | 72 means better performance: Bigger is better!""" |
| 73 test = DomPerfMeasurement | 73 test = _DomPerfMeasurement |
| 74 | 74 |
| 75 def CreatePageSet(self, options): | 75 def CreatePageSet(self, options): |
| 76 dom_perf_dir = os.path.join(util.GetChromiumSrcDir(), 'data', 'dom_perf') | 76 dom_perf_dir = os.path.join(util.GetChromiumSrcDir(), 'data', 'dom_perf') |
| 77 base_page = 'file://run.html?reportInJS=1&run=' | 77 base_page = 'file://run.html?reportInJS=1&run=' |
| 78 return page_set.PageSet.FromDict({ | 78 return page_set.PageSet.FromDict({ |
| 79 'pages': [ | 79 'pages': [ |
| 80 { 'url': base_page + 'Accessors' }, | 80 { 'url': base_page + 'Accessors' }, |
| 81 { 'url': base_page + 'CloneNodes' }, | 81 { 'url': base_page + 'CloneNodes' }, |
| 82 { 'url': base_page + 'CreateNodes' }, | 82 { 'url': base_page + 'CreateNodes' }, |
| 83 { 'url': base_page + 'DOMDivWalk' }, | 83 { 'url': base_page + 'DOMDivWalk' }, |
| 84 { 'url': base_page + 'DOMTable' }, | 84 { 'url': base_page + 'DOMTable' }, |
| 85 { 'url': base_page + 'DOMWalk' }, | 85 { 'url': base_page + 'DOMWalk' }, |
| 86 { 'url': base_page + 'Events' }, | 86 { 'url': base_page + 'Events' }, |
| 87 { 'url': base_page + 'Get+Elements' }, | 87 { 'url': base_page + 'Get+Elements' }, |
| 88 { 'url': base_page + 'GridSort' }, | 88 { 'url': base_page + 'GridSort' }, |
| 89 { 'url': base_page + 'Template' } | 89 { 'url': base_page + 'Template' } |
| 90 ] | 90 ] |
| 91 }, dom_perf_dir) | 91 }, dom_perf_dir) |
| OLD | NEW |