From 538dde876885eec7f3ed1e6354216635a39ecd06 Mon Sep 17 00:00:00 2001 From: "jeremy@chromium.org" Date: Tue, 19 Nov 2013 16:44:17 +0000 Subject: Report page load time for startup tests. Add the following stats to startup tests: * foreground_tab_load_complete - time it took for the foreground tab to load * last_tab_load_complete - time it took for the last tab to load. All of these are in ms relative to browser main entry. Changes in Chrome: Report tab load time using base::Time rather than base::TimeTicks since all times are relative to browser main entry. BUG=317481 Review URL: https://codereview.chromium.org/62833008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236009 0039d316-1c4b-4281-b951-d872f2087c98 --- .../startup_metric_utils/startup_metric_utils.cc | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'components') diff --git a/components/startup_metric_utils/startup_metric_utils.cc b/components/startup_metric_utils/startup_metric_utils.cc index 2a72b3a..beb41cd 100644 --- a/components/startup_metric_utils/startup_metric_utils.cc +++ b/components/startup_metric_utils/startup_metric_utils.cc @@ -40,6 +40,34 @@ base::Lock* GetSubsystemStartupTimeHashLock() { return slow_startup_time_hash_lock; } +// Record time of main entry so it can be read from Telemetry performance +// tests. +// TODO(jeremy): Remove once crbug.com/317481 is fixed. +void RecordMainEntryTimeHistogram() { + const int kLowWordMask = 0xFFFFFFFF; + const int kLower31BitsMask = 0x7FFFFFFF; + base::TimeDelta browser_main_entry_time_absolute = + base::TimeDelta::FromMilliseconds( + MainEntryPointTimeInternal()->ToInternalValue() / 1000.0); + + uint64 browser_main_entry_time_raw_ms = + browser_main_entry_time_absolute.InMilliseconds(); + + base::TimeDelta browser_main_entry_time_raw_ms_high_word = + base::TimeDelta::FromMilliseconds( + (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); + // Shift by one because histograms only support non-negative values. + base::TimeDelta browser_main_entry_time_raw_ms_low_word = + base::TimeDelta::FromMilliseconds( + (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); + + // A timestamp is a 64 bit value, yet histograms can only store 32 bits. + HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", + browser_main_entry_time_raw_ms_high_word); + HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", + browser_main_entry_time_raw_ms_low_word); +} + bool g_main_entry_time_was_recorded = false; bool g_startup_stats_collection_finished = false; bool g_was_slow_startup = false; @@ -88,6 +116,8 @@ const base::Time MainEntryStartTime() { } void OnBrowserStartupComplete(bool is_first_run) { + RecordMainEntryTimeHistogram(); + // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been // autostarted and the machine is under io pressure. const int64 kSevenMinutesInMilliseconds = -- cgit v1.1