Index: components/startup_metric_utils/browser/startup_metric_utils.cc |
diff --git a/components/startup_metric_utils/browser/startup_metric_utils.cc b/components/startup_metric_utils/browser/startup_metric_utils.cc |
index 76491ff103f3c6d27857a6953fb17682105bc694..d179e91139b01975dba3e590c45b4d9fe3750e72 100644 |
--- a/components/startup_metric_utils/browser/startup_metric_utils.cc |
+++ b/components/startup_metric_utils/browser/startup_metric_utils.cc |
@@ -132,6 +132,22 @@ typedef NTSTATUS (WINAPI *NtQuerySystemInformationPtr)( |
g_startup_temperature); \ |
} |
+// Returns the system uptime on process launch. |
+base::TimeDelta GetSystemUptimeOnProcessLaunch() { |
+ DCHECK(!g_process_creation_ticks.Get().is_null()); |
+ // base::SysInfo::Uptime returns the time elapsed between system boot and now. |
+ // Substract the time elapsed between process launch and now to get the time |
+ // elapsed between system boot and process launch. |
+ return base::SysInfo::Uptime() - |
+ (base::TimeTicks::Now() - g_process_creation_ticks.Get()); |
+} |
+ |
+void RecordSystemUptimeHistogram() { |
+ UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, |
+ "Startup.SystemUptime", |
+ GetSystemUptimeOnProcessLaunch()); |
+} |
+ |
// On Windows, records the number of hard-faults that have occurred in the |
// current chrome.exe process since it was started. This is a nop on other |
// platforms. |
@@ -392,6 +408,7 @@ void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
bool is_first_run) { |
AddStartupEventsForTelemetry(); |
RecordHardFaultHistogram(is_first_run); |
+ RecordSystemUptimeHistogram(); |
RecordMainEntryTimeHistogram(); |
const base::TimeTicks& process_creation_ticks = |