| 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 | 6 |
| 7 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
| 8 | 8 |
| 9 # Test how long Chrome takes to load when warm. | 9 # Test how long Chrome takes to load when warm. |
| 10 class PerfWarm(page_measurement.PageMeasurement): | 10 class PerfWarm(page_measurement.PageMeasurement): |
| 11 HISTOGRAMS_TO_RECORD = { | 11 HISTOGRAMS_TO_RECORD = { |
| 12 'messageloop_start_time' : | 12 'messageloop_start_time' : |
| 13 'Startup.BrowserMessageLoopStartTimeFromMainEntry', | 13 'Startup.BrowserMessageLoopStartTimeFromMainEntry', |
| 14 'window_display_time' : 'Startup.BrowserWindowDisplay', | 14 'window_display_time' : 'Startup.BrowserWindowDisplay', |
| 15 'open_tabs_time' : 'Startup.BrowserOpenTabs'} | 15 'open_tabs_time' : 'Startup.BrowserOpenTabs'} |
| 16 | 16 |
| 17 def __init__(self): | 17 def __init__(self): |
| 18 super(PerfWarm, self).__init__(needs_browser_restart_after_each_run=True, | 18 super(PerfWarm, self).__init__(needs_browser_restart_after_each_run=True, |
| 19 discard_first_result=True) | 19 discard_first_result=True) |
| 20 | 20 |
| 21 def CustomizeBrowserOptions(self, options): | 21 def CustomizeBrowserOptions(self, options): |
| 22 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | 22 options.AppendExtraBrowserArg('--dom-automation') |
| 23 options.AppendExtraBrowserArg( | 23 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') |
| 24 '--reduce-security-for-stats-collection-tests') | |
| 25 | 24 |
| 26 def MeasurePage(self, page, tab, results): | 25 def MeasurePage(self, page, tab, results): |
| 27 get_histogram_js = "statsCollectionController.getBrowserHistogram(\"%s\")" | 26 get_histogram_js = "domAutomationController.getBrowserHistogram(\"%s\")" |
| 28 | 27 |
| 29 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems(): | 28 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems(): |
| 30 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name) | 29 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name) |
| 31 result = json.loads(result) | 30 result = json.loads(result) |
| 32 measured_time = 0 | 31 measured_time = 0 |
| 33 | 32 |
| 34 if 'sum' in result: | 33 if 'sum' in result: |
| 35 # For all the histograms logged here, there's a single entry so sum | 34 # For all the histograms logged here, there's a single entry so sum |
| 36 # is the exact value for that entry. | 35 # is the exact value for that entry. |
| 37 measured_time = result['sum'] | 36 measured_time = result['sum'] |
| 38 elif 'buckets' in result: | 37 elif 'buckets' in result: |
| 39 measured_time = \ | 38 measured_time = \ |
| 40 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 | 39 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 |
| 41 | 40 |
| 42 results.Add(display_name, 'ms', measured_time) | 41 results.Add(display_name, 'ms', measured_time) |
| OLD | NEW |