Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Unified Diff: components/startup_metric_utils/browser/startup_metric_utils.cc

Issue 1556103002: Add Startup.SystemUptime histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test error on Android. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 914c960dc377f4a668a67ab2a758fd8f6a6d25e4..6594376949548637e720e4a3df86c084f118d862 100644
--- a/components/startup_metric_utils/browser/startup_metric_utils.cc
+++ b/components/startup_metric_utils/browser/startup_metric_utils.cc
@@ -135,6 +135,30 @@ typedef NTSTATUS (WINAPI *NtQuerySystemInformationPtr)(
g_startup_temperature); \
}
+// Returns the system uptime on process launch.
+base::TimeDelta GetSystemUptimeOnProcessLaunch() {
+ // Process launch time is not available on Android.
+ if (g_process_creation_ticks.Get().is_null())
+ return base::TimeDelta();
+
+ // 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() {
+ const base::TimeDelta system_uptime_on_process_launch =
+ GetSystemUptimeOnProcessLaunch();
+ if (system_uptime_on_process_launch.is_zero())
+ return;
+
+ 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.
@@ -395,6 +419,7 @@ void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
bool is_first_run) {
AddStartupEventsForTelemetry();
RecordHardFaultHistogram(is_first_run);
+ RecordSystemUptimeHistogram();
RecordMainEntryTimeHistogram();
const base::TimeTicks& process_creation_ticks =
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698