OLD | NEW |
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 Loading... |
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 if (is_first_run) { |
89 "Startup.BrowserMessageLoopStartTimeFromMainEntry", | 89 UMA_HISTOGRAM_LONG_TIMES( |
90 startup_time_from_main_entry); | 90 "Startup.BrowserMessageLoopStartTimeFromMainEntry.FirstRun", |
| 91 startup_time_from_main_entry); |
| 92 } else { |
| 93 UMA_HISTOGRAM_LONG_TIMES( |
| 94 "Startup.BrowserMessageLoopStartTimeFromMainEntry", |
| 95 startup_time_from_main_entry); |
| 96 } |
91 | 97 |
92 // Create another histogram that records the exact number for use by | 98 // Create another histogram that records the exact number for use by |
93 // performance tests. | 99 // performance tests. |
94 int64 startup_time_from_main_entry_ms = | 100 int64 startup_time_from_main_entry_ms = |
95 startup_time_from_main_entry.InMilliseconds(); | 101 startup_time_from_main_entry.InMilliseconds(); |
96 HISTOGRAM_ENUMERATION( | 102 HISTOGRAM_ENUMERATION( |
97 "Startup.BrowserMessageLoopStartTimeFromMainEntry_Exact", | 103 "Startup.BrowserMessageLoopStartTimeFromMainEntry_Exact", |
98 startup_time_from_main_entry_ms, | 104 startup_time_from_main_entry_ms, |
99 startup_time_from_main_entry_ms); | 105 startup_time_from_main_entry_ms); |
100 | 106 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 SubsystemStartupTimeHash* hash = GetSubsystemStartupTimeHash(); | 161 SubsystemStartupTimeHash* hash = GetSubsystemStartupTimeHash(); |
156 // Only record the initial sample for a given histogram. | 162 // Only record the initial sample for a given histogram. |
157 if (hash->find(histogram_name_) != hash->end()) | 163 if (hash->find(histogram_name_) != hash->end()) |
158 return; | 164 return; |
159 | 165 |
160 (*hash)[histogram_name_] = | 166 (*hash)[histogram_name_] = |
161 base::TimeTicks::Now() - start_time_; | 167 base::TimeTicks::Now() - start_time_; |
162 } | 168 } |
163 | 169 |
164 } // namespace startup_metric_utils | 170 } // namespace startup_metric_utils |
OLD | NEW |