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 "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(type, basename, \ | 125 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(type, basename, \ |
126 end_ticks - begin_ticks) \ | 126 end_ticks - begin_ticks) \ |
127 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \ | 127 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \ |
128 "startup", basename, 0, begin_ticks.ToInternalValue(), "Temperature", \ | 128 "startup", basename, 0, begin_ticks.ToInternalValue(), "Temperature", \ |
129 g_startup_temperature); \ | 129 g_startup_temperature); \ |
130 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1( \ | 130 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1( \ |
131 "startup", basename, 0, end_ticks.ToInternalValue(), "Temperature", \ | 131 "startup", basename, 0, end_ticks.ToInternalValue(), "Temperature", \ |
132 g_startup_temperature); \ | 132 g_startup_temperature); \ |
133 } | 133 } |
134 | 134 |
135 // Returns the time elapsed between system boot and process launch. | |
136 base::TimeDelta GetStartupUptime() { | |
gab
2016/01/05 15:10:00
GetSystemUptimeOnProcessLaunch() ?
fdoray
2016/01/05 15:34:01
Done.
| |
137 DCHECK(!g_process_creation_ticks.Get().is_null()); | |
138 // base::SysInfo::Uptime returns the time elapsed between system boot and now. | |
139 // Substract the time elapsed between process launch and now to get the time | |
140 // elapsed between system boot and process launch. | |
141 return base::SysInfo::Uptime() - | |
142 (base::TimeTicks::Now() - g_process_creation_ticks.Get()); | |
143 } | |
144 | |
145 void RecordUptimeHistogram() { | |
146 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, | |
147 "Startup.Uptime", GetStartupUptime()); | |
gab
2016/01/05 15:10:00
"Startup.SystemUptime" ? (i.e. to make it clear it
fdoray
2016/01/05 15:34:01
Done.
| |
148 } | |
149 | |
135 // On Windows, records the number of hard-faults that have occurred in the | 150 // On Windows, records the number of hard-faults that have occurred in the |
136 // current chrome.exe process since it was started. This is a nop on other | 151 // current chrome.exe process since it was started. This is a nop on other |
137 // platforms. | 152 // platforms. |
138 // crbug.com/476923 | 153 // crbug.com/476923 |
139 // TODO(chrisha): If this proves useful, use it to split startup stats in two. | 154 // TODO(chrisha): If this proves useful, use it to split startup stats in two. |
140 void RecordHardFaultHistogram(bool is_first_run) { | 155 void RecordHardFaultHistogram(bool is_first_run) { |
141 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
142 uint32_t hard_fault_count = 0; | 157 uint32_t hard_fault_count = 0; |
143 | 158 |
144 // Don't log a histogram value if unable to get the hard fault count. | 159 // Don't log a histogram value if unable to get the hard fault count. |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 const std::string exe_load_ticks = | 400 const std::string exe_load_ticks = |
386 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); | 401 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); |
387 scoped_ptr<base::Environment> env(base::Environment::Create()); | 402 scoped_ptr<base::Environment> env(base::Environment::Create()); |
388 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); | 403 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); |
389 } | 404 } |
390 | 405 |
391 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 406 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
392 bool is_first_run) { | 407 bool is_first_run) { |
393 AddStartupEventsForTelemetry(); | 408 AddStartupEventsForTelemetry(); |
394 RecordHardFaultHistogram(is_first_run); | 409 RecordHardFaultHistogram(is_first_run); |
410 RecordUptimeHistogram(); | |
395 RecordMainEntryTimeHistogram(); | 411 RecordMainEntryTimeHistogram(); |
396 | 412 |
397 const base::TimeTicks& process_creation_ticks = | 413 const base::TimeTicks& process_creation_ticks = |
398 g_process_creation_ticks.Get(); | 414 g_process_creation_ticks.Get(); |
399 if (!is_first_run && !process_creation_ticks.is_null()) { | 415 if (!is_first_run && !process_creation_ticks.is_null()) { |
400 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 416 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
401 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", | 417 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", |
402 process_creation_ticks, ticks); | 418 process_creation_ticks, ticks); |
403 } | 419 } |
404 | 420 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 | 557 |
542 base::TimeTicks MainEntryPointTicks() { | 558 base::TimeTicks MainEntryPointTicks() { |
543 return g_browser_main_entry_point_ticks.Get(); | 559 return g_browser_main_entry_point_ticks.Get(); |
544 } | 560 } |
545 | 561 |
546 StartupTemperature GetStartupTemperature() { | 562 StartupTemperature GetStartupTemperature() { |
547 return g_startup_temperature; | 563 return g_startup_temperature; |
548 } | 564 } |
549 | 565 |
550 } // namespace startup_metric_utils | 566 } // namespace startup_metric_utils |
OLD | NEW |