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 system uptime on process launch. |
| 136 base::TimeDelta GetSystemUptimeOnProcessLaunch() { |
| 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 RecordSystemUptimeHistogram() { |
| 146 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, |
| 147 "Startup.SystemUptime", |
| 148 GetSystemUptimeOnProcessLaunch()); |
| 149 } |
| 150 |
135 // On Windows, records the number of hard-faults that have occurred in the | 151 // 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 | 152 // current chrome.exe process since it was started. This is a nop on other |
137 // platforms. | 153 // platforms. |
138 // crbug.com/476923 | 154 // crbug.com/476923 |
139 // TODO(chrisha): If this proves useful, use it to split startup stats in two. | 155 // TODO(chrisha): If this proves useful, use it to split startup stats in two. |
140 void RecordHardFaultHistogram(bool is_first_run) { | 156 void RecordHardFaultHistogram(bool is_first_run) { |
141 #if defined(OS_WIN) | 157 #if defined(OS_WIN) |
142 uint32_t hard_fault_count = 0; | 158 uint32_t hard_fault_count = 0; |
143 | 159 |
144 // Don't log a histogram value if unable to get the hard fault count. | 160 // 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 = | 401 const std::string exe_load_ticks = |
386 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); | 402 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); |
387 scoped_ptr<base::Environment> env(base::Environment::Create()); | 403 scoped_ptr<base::Environment> env(base::Environment::Create()); |
388 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); | 404 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); |
389 } | 405 } |
390 | 406 |
391 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 407 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
392 bool is_first_run) { | 408 bool is_first_run) { |
393 AddStartupEventsForTelemetry(); | 409 AddStartupEventsForTelemetry(); |
394 RecordHardFaultHistogram(is_first_run); | 410 RecordHardFaultHistogram(is_first_run); |
| 411 RecordSystemUptimeHistogram(); |
395 RecordMainEntryTimeHistogram(); | 412 RecordMainEntryTimeHistogram(); |
396 | 413 |
397 const base::TimeTicks& process_creation_ticks = | 414 const base::TimeTicks& process_creation_ticks = |
398 g_process_creation_ticks.Get(); | 415 g_process_creation_ticks.Get(); |
399 if (!is_first_run && !process_creation_ticks.is_null()) { | 416 if (!is_first_run && !process_creation_ticks.is_null()) { |
400 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 417 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
401 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", | 418 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", |
402 process_creation_ticks, ticks); | 419 process_creation_ticks, ticks); |
403 } | 420 } |
404 | 421 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 558 |
542 base::TimeTicks MainEntryPointTicks() { | 559 base::TimeTicks MainEntryPointTicks() { |
543 return g_browser_main_entry_point_ticks.Get(); | 560 return g_browser_main_entry_point_ticks.Get(); |
544 } | 561 } |
545 | 562 |
546 StartupTemperature GetStartupTemperature() { | 563 StartupTemperature GetStartupTemperature() { |
547 return g_startup_temperature; | 564 return g_startup_temperature; |
548 } | 565 } |
549 | 566 |
550 } // namespace startup_metric_utils | 567 } // namespace startup_metric_utils |
OLD | NEW |