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 | 4 |
5 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | 5 #include "components/startup_metric_utils/browser/startup_metric_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 return; | 179 return; |
180 | 180 |
181 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, | 181 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, |
182 "Startup.SystemUptime", | 182 "Startup.SystemUptime", |
183 GetSystemUptimeOnProcessLaunch()); | 183 GetSystemUptimeOnProcessLaunch()); |
184 } | 184 } |
185 | 185 |
186 // On Windows, records the number of hard-faults that have occurred in the | 186 // On Windows, records the number of hard-faults that have occurred in the |
187 // current chrome.exe process since it was started. A version of the histograms | 187 // current chrome.exe process since it was started. A version of the histograms |
188 // recorded in this method suffixed by |same_version_startup_count| will also be | 188 // recorded in this method suffixed by |same_version_startup_count| will also be |
189 // recorded (unless |same_version_startup_count| is 0 which indicates it's | 189 // recorded. This is a nop on other platforms. |
190 // unknown). This is a nop on other platforms. | |
191 void RecordHardFaultHistogram(int same_version_startup_count) { | 190 void RecordHardFaultHistogram(int same_version_startup_count) { |
192 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
193 uint32_t hard_fault_count = 0; | 192 uint32_t hard_fault_count = 0; |
194 | 193 |
195 // Don't record histograms if unable to get the hard fault count. | 194 // Don't record histograms if unable to get the hard fault count. |
196 if (!GetHardFaultCountForCurrentProcess(&hard_fault_count)) | 195 if (!GetHardFaultCountForCurrentProcess(&hard_fault_count)) |
197 return; | 196 return; |
198 | 197 |
199 std::string same_version_startup_count_suffix; | 198 // Histograms below will be suffixed by |same_version_startup_count| up to |
200 if (same_version_startup_count != 0) { | 199 // |kMaxSameVersionCountRecorded|, higher counts will be grouped in the |
201 // Histograms below will be suffixed by |same_version_startup_count| up to | 200 // ".Over" suffix. Make sure to reflect changes to |
202 // |kMaxSameVersionCountRecorded|, higher counts will be grouped in the | 201 // kMaxSameVersionCountRecorded in the "SameVersionStartupCounts" histogram |
203 // ".Over" suffix. Make sure to reflect changes to | 202 // suffix. |
204 // kMaxSameVersionCountRecorded in the "SameVersionStartupCounts" histogram | 203 std::string same_version_startup_count_suffix("."); |
205 // suffix. | 204 constexpr int kMaxSameVersionCountRecorded = 9; |
206 const int kMaxSameVersionCountRecorded = 9; | 205 same_version_startup_count_suffix.push_back('.'); |
gab
2016/07/07 19:05:31
It starts with a '.' on 203 this adds a second one
fdoray
2016/07/08 14:20:21
Done.
| |
207 same_version_startup_count_suffix.push_back('.'); | 206 DCHECK_GE(same_version_startup_count, 1); |
208 DCHECK_GE(same_version_startup_count, 1); | 207 if (same_version_startup_count <= kMaxSameVersionCountRecorded) { |
209 if (same_version_startup_count <= kMaxSameVersionCountRecorded) { | 208 same_version_startup_count_suffix.append( |
210 same_version_startup_count_suffix.append( | 209 base::IntToString(same_version_startup_count)); |
211 base::IntToString(same_version_startup_count)); | 210 } else { |
212 } else { | 211 same_version_startup_count_suffix.append("Over"); |
213 same_version_startup_count_suffix.append("Over"); | |
214 } | |
215 } | 212 } |
216 | 213 |
217 // Hard fault counts are expected to be in the thousands range, | 214 // Hard fault counts are expected to be in the thousands range, |
218 // corresponding to faulting in ~10s of MBs of code ~10s of KBs at a time. | 215 // corresponding to faulting in ~10s of MBs of code ~10s of KBs at a time. |
219 // (Observed to vary from 1000 to 10000 on various test machines and | 216 // (Observed to vary from 1000 to 10000 on various test machines and |
220 // platforms.) | 217 // platforms.) |
221 const char kHardFaultCountHistogram[] = | 218 const char kHardFaultCountHistogram[] = |
222 "Startup.BrowserMessageLoopStartHardFaultCount"; | 219 "Startup.BrowserMessageLoopStartHardFaultCount"; |
223 UMA_HISTOGRAM_CUSTOM_COUNTS(kHardFaultCountHistogram, hard_fault_count, 1, | 220 UMA_HISTOGRAM_CUSTOM_COUNTS(kHardFaultCountHistogram, hard_fault_count, 1, |
224 40000, 50); | 221 40000, 50); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 void RecordExeMainEntryPointTime(const base::Time& time) { | 535 void RecordExeMainEntryPointTime(const base::Time& time) { |
539 const std::string exe_load_ticks = | 536 const std::string exe_load_ticks = |
540 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); | 537 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); |
541 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 538 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
542 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); | 539 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); |
543 } | 540 } |
544 | 541 |
545 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 542 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
546 bool is_first_run, | 543 bool is_first_run, |
547 PrefService* pref_service) { | 544 PrefService* pref_service) { |
548 int same_version_startup_count = 0; | 545 DCHECK(pref_service); |
549 if (pref_service) | 546 |
550 same_version_startup_count = RecordSameVersionStartupCount(pref_service); | 547 const int same_version_startup_count = |
548 RecordSameVersionStartupCount(pref_service); | |
551 // Keep RecordHardFaultHistogram() first as much as possible as many other | 549 // Keep RecordHardFaultHistogram() first as much as possible as many other |
552 // histograms depend on it setting |g_startup_temperature|. | 550 // histograms depend on it setting |g_startup_temperature|. |
553 RecordHardFaultHistogram(same_version_startup_count); | 551 RecordHardFaultHistogram(same_version_startup_count); |
554 AddStartupEventsForTelemetry(); | 552 AddStartupEventsForTelemetry(); |
555 if (pref_service) | 553 RecordTimeSinceLastStartup(pref_service); |
556 RecordTimeSinceLastStartup(pref_service); | |
557 RecordSystemUptimeHistogram(); | 554 RecordSystemUptimeHistogram(); |
558 RecordMainEntryTimeHistogram(); | 555 RecordMainEntryTimeHistogram(); |
559 | 556 |
560 const base::TimeTicks& process_creation_ticks = | 557 const base::TimeTicks& process_creation_ticks = |
561 g_process_creation_ticks.Get(); | 558 g_process_creation_ticks.Get(); |
562 if (!is_first_run && !process_creation_ticks.is_null()) { | 559 if (!is_first_run && !process_creation_ticks.is_null()) { |
563 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 560 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
564 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", | 561 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", |
565 process_creation_ticks, ticks); | 562 process_creation_ticks, ticks); |
566 } | 563 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 | 701 |
705 base::TimeTicks MainEntryPointTicks() { | 702 base::TimeTicks MainEntryPointTicks() { |
706 return g_browser_main_entry_point_ticks.Get(); | 703 return g_browser_main_entry_point_ticks.Get(); |
707 } | 704 } |
708 | 705 |
709 StartupTemperature GetStartupTemperature() { | 706 StartupTemperature GetStartupTemperature() { |
710 return g_startup_temperature; | 707 return g_startup_temperature; |
711 } | 708 } |
712 | 709 |
713 } // namespace startup_metric_utils | 710 } // namespace startup_metric_utils |
OLD | NEW |