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

Unified Diff: src/platform/power_manager/send_metrics_on_resume

Issue 2079014: Log time in suspend. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Simplify the option parsing code for now. Created 10 years, 7 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 | « src/platform/init/dump-boot-stats.conf ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/power_manager/send_metrics_on_resume
diff --git a/src/platform/power_manager/send_metrics_on_resume b/src/platform/power_manager/send_metrics_on_resume
new file mode 100755
index 0000000000000000000000000000000000000000..2910727c05fbfa43c3e33e7361e474d7053b15fd
--- /dev/null
+++ b/src/platform/power_manager/send_metrics_on_resume
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This script collects UMA metrics when the device is coming out of
+# suspend or, if the machine shut down while in suspend, at boot time.
+#
+# Usage:
+# -b -- indicates that this script is invoked at boot time.
+
+F_SUSPEND_AT=/var/log/metrics/suspend-to-ram-time
+[ -r $F_SUSPEND_AT ] || exit
+
+RESUME_AT=`cat /sys/class/rtc/rtc0/since_epoch`
+SUSPEND_AT=`cat $F_SUSPEND_AT`
+
+rm -f $F_SUSPEND_AT
+
+TIME_IN_SUSPEND_NAME=Power.TimeInSuspendAtResume
+[ "$1" = "-b" ] && TIME_IN_SUSPEND_NAME=Power.TimeInSuspendAtBoot
+
+if [ $RESUME_AT -gt $SUSPEND_AT ]; then
+ # Converts seconds to minutes rounding to the nearest whole minute.
+ TIME_IN_SUSPEND=$((($RESUME_AT - $SUSPEND_AT + 30) / 60))
+ /usr/bin/metrics_client $TIME_IN_SUSPEND_NAME $TIME_IN_SUSPEND 1 10000 50
+fi
« no previous file with comments | « src/platform/init/dump-boot-stats.conf ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698