| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import json |
| 6 |
| 7 from metrics import histogram_util |
| 8 from telemetry.page import page_measurement |
| 9 |
| 10 class SigninMeasurement(page_measurement.PageMeasurement): |
| 11 HISTOGRAMS_SUFFIXES = ['PreGaiaLoadTime', 'GaiaLoadTime'] |
| 12 |
| 13 def __init__(self, restart_after_each_run = True): |
| 14 super(SigninMeasurement, self).__init__( |
| 15 needs_browser_restart_after_each_run=restart_after_each_run) |
| 16 self._close_tabs_before_run = False |
| 17 self._use_same_tab = True |
| 18 self._pageset_repeat_iters = 0 |
| 19 self._trace_name = 'InlineUI_LoadAfterStartupDuration' |
| 20 self._histogram_prefix = 'Signin.InlineUI.LoadAfterStartup.' |
| 21 |
| 22 def CustomizeBrowserOptions(self, options): |
| 23 options.AppendExtraBrowserArgs('--enable-stats-collection-bindings') |
| 24 self._pageset_repeat_iters = options.pageset_repeat_iters |
| 25 |
| 26 def TabForPage(self, page, browser): |
| 27 return browser.tabs[0] if self._use_same_tab else browser.tabs.New() |
| 28 |
| 29 def MeasurePage(self, page, tab, results): |
| 30 total_num_tabs = 1 if self._use_same_tab else \ |
| 31 len(page.page_set.pages) * self._pageset_repeat_iters + 1 |
| 32 if len(tab.browser.tabs) != total_num_tabs: |
| 33 return |
| 34 |
| 35 tab.WaitForJavaScriptExpression('window.__login_ui_initialized', 5000) |
| 36 |
| 37 for suffix in self.HISTOGRAMS_SUFFIXES: |
| 38 load_histogram = json.loads(histogram_util.GetHistogram( |
| 39 histogram_util.BROWSER_HISTOGRAM, |
| 40 self._histogram_prefix + suffix, tab)) |
| 41 load_histogram_count = load_histogram['count'] \ |
| 42 if 'count' in load_histogram else 0 |
| 43 expected_histogram_count = 1 if self._use_same_tab else total_num_tabs -1 |
| 44 if load_histogram_count != expected_histogram_count: |
| 45 raise Exception( |
| 46 'Unexpected number of histograms, expected:%d, actual:%d' |
| 47 % (expected_histogram_count, load_histogram_count)) |
| 48 |
| 49 results.Add(self._trace_name + '_' + suffix, 'ms', |
| 50 load_histogram['sum'] / load_histogram_count) |
| 51 |
| 52 |
| 53 class SigninMultiTabMeasurement(SigninMeasurement): |
| 54 def __init__(self): |
| 55 super(SigninMultiTabMeasurement, self).__init__( |
| 56 restart_after_each_run=False) |
| 57 self._use_same_tab = False |
| 58 |
| 59 |
| 60 class SigninStartUpMeasurement(SigninMeasurement): |
| 61 def __init__(self): |
| 62 super(SigninStartUpMeasurement, self).__init__() |
| 63 self._trace_name = 'InlineUI_LoadOnStartupDuration' |
| 64 self._histogram_prefix = 'Signin.InlineUI.LoadOnStartup.' |
| 65 |
| 66 def CustomizeBrowserOptions(self, options): |
| 67 super(SigninStartUpMeasurement, self).CustomizeBrowserOptions(options) |
| 68 options.AppendExtraBrowserArgs('--force-signin-promo') |
| 69 |
| 70 def RunNavigateSteps(self, page, tab): |
| 71 pass |
| OLD | NEW |