| 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 import collections | 4 import collections |
| 5 import json | 5 import json |
| 6 import logging | 6 import logging |
| 7 | 7 |
| 8 from telemetry.core import exceptions | 8 from telemetry.core import exceptions |
| 9 from telemetry.value import histogram_util | 9 from telemetry.value import histogram_util |
| 10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
| 11 | 11 |
| 12 from metrics import Metric | 12 from metrics import Metric |
| 13 | 13 |
| 14 | 14 |
| 15 class StartupMetric(Metric): | 15 class StartupMetric(Metric): |
| 16 "A metric for browser startup time." | 16 "A metric for browser startup time." |
| 17 | 17 |
| 18 # Seconds to wait for page loading complete. | 18 # Seconds to wait for page loading complete. |
| 19 DEFAULT_LOADING_TIMEOUT = 90 | 19 DEFAULT_LOADING_TIMEOUT = 90 |
| 20 | 20 |
| 21 HISTOGRAMS_TO_RECORD = { | 21 HISTOGRAMS_TO_RECORD = { |
| 22 'messageloop_start_time' : | 22 'messageloop_start_time' : |
| 23 'Startup.BrowserMessageLoopStartTimeFromMainEntry', | 23 'Startup.BrowserMessageLoopStartTimeFromMainEntry', |
| 24 'window_display_time' : 'Startup.BrowserWindowDisplay', | 24 'window_display_time' : 'Startup.BrowserWindowDisplay', |
| 25 'open_tabs_time' : 'Startup.BrowserOpenTabs', | 25 'open_tabs_time' : 'Startup.BrowserOpenTabs', |
| 26 'first_non_empty_paint_time' : 'Startup.FirstWebContents.NonEmptyPaint', | 26 'first_non_empty_paint_time' : 'Startup.FirstWebContents.NonEmptyPaint2', |
| 27 'first_main_frame_load_time' : 'Startup.FirstWebContents.MainFrameLoad'} | 27 'first_main_frame_load_time' : 'Startup.FirstWebContents.MainFrameLoad2'} |
| 28 | 28 |
| 29 def Start(self, page, tab): | 29 def Start(self, page, tab): |
| 30 raise NotImplementedError() | 30 raise NotImplementedError() |
| 31 | 31 |
| 32 def Stop(self, page, tab): | 32 def Stop(self, page, tab): |
| 33 raise NotImplementedError() | 33 raise NotImplementedError() |
| 34 | 34 |
| 35 def _GetBrowserMainEntryTime(self, tab): | 35 def _GetBrowserMainEntryTime(self, tab): |
| 36 """Returns the main entry time (in ms) of the browser.""" | 36 """Returns the main entry time (in ms) of the browser.""" |
| 37 histogram_type = histogram_util.BROWSER_HISTOGRAM | 37 histogram_type = histogram_util.BROWSER_HISTOGRAM |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 results.AddValue(scalar.ScalarValue( | 120 results.AddValue(scalar.ScalarValue( |
| 121 results.current_page, display_name, 'ms', measured_time)) | 121 results.current_page, display_name, 'ms', measured_time)) |
| 122 | 122 |
| 123 # Get tab load times. | 123 # Get tab load times. |
| 124 browser_main_entry_time_ms = self._GetBrowserMainEntryTime(tab) | 124 browser_main_entry_time_ms = self._GetBrowserMainEntryTime(tab) |
| 125 if browser_main_entry_time_ms is None: | 125 if browser_main_entry_time_ms is None: |
| 126 print "Outdated Chrome version, browser main entry time not supported." | 126 print "Outdated Chrome version, browser main entry time not supported." |
| 127 return | 127 return |
| 128 self._RecordTabLoadTimes(tab, browser_main_entry_time_ms, results) | 128 self._RecordTabLoadTimes(tab, browser_main_entry_time_ms, results) |
| OLD | NEW |