Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(972)

Side by Side Diff: chrome/common/startup_metric_utils.cc

Issue 14946003: Record first run startup metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/common/startup_metric_utils.h" 5 #include "chrome/common/startup_metric_utils.h"
6 6
7 #include "base/hash_tables.h" 7 #include "base/hash_tables.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 g_main_entry_time_was_recorded = true; 58 g_main_entry_time_was_recorded = true;
59 MainEntryPointTimeInternal(); 59 MainEntryPointTimeInternal();
60 } 60 }
61 61
62 // Return the time recorded by RecordMainEntryPointTime(). 62 // Return the time recorded by RecordMainEntryPointTime().
63 const base::Time MainEntryStartTime() { 63 const base::Time MainEntryStartTime() {
64 DCHECK(g_main_entry_time_was_recorded); 64 DCHECK(g_main_entry_time_was_recorded);
65 return *MainEntryPointTimeInternal(); 65 return *MainEntryPointTimeInternal();
66 } 66 }
67 67
68 void OnBrowserStartupComplete() { 68 void OnBrowserStartupComplete(bool is_first_run) {
69 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been 69 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been
70 // autostarted and the machine is under io pressure. 70 // autostarted and the machine is under io pressure.
71 const int64 kSevenMinutesInMilliseconds = 71 const int64 kSevenMinutesInMilliseconds =
72 base::TimeDelta::FromMinutes(7).InMilliseconds(); 72 base::TimeDelta::FromMinutes(7).InMilliseconds();
73 if (base::SysInfo::Uptime() < kSevenMinutesInMilliseconds) { 73 if (base::SysInfo::Uptime() < kSevenMinutesInMilliseconds) {
74 g_startup_stats_collection_finished = true; 74 g_startup_stats_collection_finished = true;
75 return; 75 return;
76 } 76 }
77 77
78 // The Startup.BrowserMessageLoopStartTime histogram recorded in 78 // The Startup.BrowserMessageLoopStartTime histogram recorded in
79 // chrome_browser_main.cc exhibits instability in the field which limits its 79 // chrome_browser_main.cc exhibits instability in the field which limits its
80 // usefulness in all scenarios except when we have a very large sample size. 80 // usefulness in all scenarios except when we have a very large sample size.
81 // Attempt to mitigate this with a new metric: 81 // Attempt to mitigate this with a new metric:
82 // * Measure time from main entry rather than the OS' notion of process start 82 // * Measure time from main entry rather than the OS' notion of process start
83 // time. 83 // time.
84 // * Only measure launches that occur 7 minutes after boot to try to avoid 84 // * Only measure launches that occur 7 minutes after boot to try to avoid
85 // cases where Chrome is auto-started and IO is heavily loaded. 85 // cases where Chrome is auto-started and IO is heavily loaded.
86 base::TimeDelta startup_time_from_main_entry = 86 base::TimeDelta startup_time_from_main_entry =
87 base::Time::Now() - MainEntryStartTime(); 87 base::Time::Now() - MainEntryStartTime();
88 UMA_HISTOGRAM_LONG_TIMES( 88 UMA_HISTOGRAM_LONG_TIMES(
89 "Startup.BrowserMessageLoopStartTimeFromMainEntry", 89 is_first_run ?
90 "Startup.FirstRun.BrowserMessageLoopStartTimeFromMainEntry" :
91 "Startup.BrowserMessageLoopStartTimeFromMainEntry",
gab 2013/05/06 16:19:54 Also split this into two explicit calls since thes
90 startup_time_from_main_entry); 92 startup_time_from_main_entry);
91 93
92 // Create another histogram that records the exact number for use by 94 // Create another histogram that records the exact number for use by
93 // performance tests. 95 // performance tests.
94 int64 startup_time_from_main_entry_ms = 96 int64 startup_time_from_main_entry_ms =
95 startup_time_from_main_entry.InMilliseconds(); 97 startup_time_from_main_entry.InMilliseconds();
96 HISTOGRAM_ENUMERATION( 98 HISTOGRAM_ENUMERATION(
97 "Startup.BrowserMessageLoopStartTimeFromMainEntry_Exact", 99 is_first_run ?
100 "Startup.FirstRun.BrowserMessageLoopStartTimeFromMainEntry_Exact" :
jeremy 2013/05/05 12:35:56 This histogram is only used for perf tests and is
gab 2013/05/06 16:19:54 Done.
101 "Startup.BrowserMessageLoopStartTimeFromMainEntry_Exact",
98 startup_time_from_main_entry_ms, 102 startup_time_from_main_entry_ms,
99 startup_time_from_main_entry_ms); 103 startup_time_from_main_entry_ms);
100 104
101 // Record histograms for the subsystem times for startups > 10 seconds. 105 // Record histograms for the subsystem times for startups > 10 seconds.
102 const base::TimeDelta kTenSeconds = base::TimeDelta::FromSeconds(10); 106 const base::TimeDelta kTenSeconds = base::TimeDelta::FromSeconds(10);
103 if (startup_time_from_main_entry < kTenSeconds) { 107 if (startup_time_from_main_entry < kTenSeconds) {
104 g_startup_stats_collection_finished = true; 108 g_startup_stats_collection_finished = true;
105 return; 109 return;
106 } 110 }
107 111
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 SubsystemStartupTimeHash* hash = GetSubsystemStartupTimeHash(); 159 SubsystemStartupTimeHash* hash = GetSubsystemStartupTimeHash();
156 // Only record the initial sample for a given histogram. 160 // Only record the initial sample for a given histogram.
157 if (hash->find(histogram_name_) != hash->end()) 161 if (hash->find(histogram_name_) != hash->end())
158 return; 162 return;
159 163
160 (*hash)[histogram_name_] = 164 (*hash)[histogram_name_] =
161 base::TimeTicks::Now() - start_time_; 165 base::TimeTicks::Now() - start_time_;
162 } 166 }
163 167
164 } // namespace startup_metric_utils 168 } // namespace startup_metric_utils
OLDNEW
« chrome/common/startup_metric_utils.h ('K') | « chrome/common/startup_metric_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698