| 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 import json | 5 import json |
| 6 | 6 |
| 7 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
| 8 | 8 |
| 9 class Startup(page_measurement.PageMeasurement): | 9 class Startup(page_measurement.PageMeasurement): |
| 10 """Performs a measurement of Chromium's startup performance. | 10 """Performs a measurement of Chromium's startup performance. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 def CustomizeBrowserOptions(self, options): | 33 def CustomizeBrowserOptions(self, options): |
| 34 # TODO: Once the bots start running benchmarks, enforce that either --warm | 34 # TODO: Once the bots start running benchmarks, enforce that either --warm |
| 35 # or --cold is explicitly specified. | 35 # or --cold is explicitly specified. |
| 36 # assert options.warm != options.cold, \ | 36 # assert options.warm != options.cold, \ |
| 37 # "You must specify either --warm or --cold" | 37 # "You must specify either --warm or --cold" |
| 38 if options.cold: | 38 if options.cold: |
| 39 options.clear_sytem_cache_for_browser_and_profile_on_start = True | 39 options.clear_sytem_cache_for_browser_and_profile_on_start = True |
| 40 else: | 40 else: |
| 41 self.discard_first_result = True | 41 self.discard_first_result = True |
| 42 | 42 |
| 43 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | 43 options.AppendExtraBrowserArgs([ |
| 44 '--enable-stats-collection-bindings', |
| 44 | 45 |
| 45 # Old commandline flags used for reference builds. | 46 # Old commandline flags used for reference builds. |
| 46 options.AppendExtraBrowserArg('--dom-automation') | 47 '--dom-automation', |
| 47 options.AppendExtraBrowserArg( | 48 '--reduce-security-for-dom-automation-tests' |
| 48 '--reduce-security-for-dom-automation-tests') | 49 ]) |
| 49 | 50 |
| 50 def MeasurePage(self, page, tab, results): | 51 def MeasurePage(self, page, tab, results): |
| 51 # TODO(jeremy): Remove references to | 52 # TODO(jeremy): Remove references to |
| 52 # domAutomationController.getBrowserHistogram when we update the reference | 53 # domAutomationController.getBrowserHistogram when we update the reference |
| 53 # builds. | 54 # builds. |
| 54 get_histogram_js = ('(window.statsCollectionController ?' | 55 get_histogram_js = ('(window.statsCollectionController ?' |
| 55 'statsCollectionController :' | 56 'statsCollectionController :' |
| 56 'domAutomationController).getBrowserHistogram("%s")') | 57 'domAutomationController).getBrowserHistogram("%s")') |
| 57 | 58 |
| 58 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems(): | 59 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems(): |
| 59 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name) | 60 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name) |
| 60 result = json.loads(result) | 61 result = json.loads(result) |
| 61 measured_time = 0 | 62 measured_time = 0 |
| 62 | 63 |
| 63 if 'sum' in result: | 64 if 'sum' in result: |
| 64 # For all the histograms logged here, there's a single entry so sum | 65 # For all the histograms logged here, there's a single entry so sum |
| 65 # is the exact value for that entry. | 66 # is the exact value for that entry. |
| 66 measured_time = result['sum'] | 67 measured_time = result['sum'] |
| 67 elif 'buckets' in result: | 68 elif 'buckets' in result: |
| 68 measured_time = \ | 69 measured_time = \ |
| 69 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 | 70 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 |
| 70 | 71 |
| 71 results.Add(display_name, 'ms', measured_time) | 72 results.Add(display_name, 'ms', measured_time) |
| OLD | NEW |