diff options
author | James Hawkins <jhawkins@google.com> | 2017-02-06 10:46:54 -0800 |
---|---|---|
committer | James Hawkins <jhawkins@google.com> | 2017-02-07 15:43:32 -0800 |
commit | 26f40c04c3ad80e2bc449990010d39d1c1b9a5f0 (patch) | |
tree | dc8aae8ca90822f9f9f578c40255fc7c93db76df /bootstat/bootstat.cpp | |
parent | 564aeca94e18cd708f93619551e05b3d59d4abe2 (diff) | |
download | system_core-26f40c04c3ad80e2bc449990010d39d1c1b9a5f0.tar.gz system_core-26f40c04c3ad80e2bc449990010d39d1c1b9a5f0.tar.bz2 system_core-26f40c04c3ad80e2bc449990010d39d1c1b9a5f0.zip |
bootstat: Remove custom uptime parser in favor of elapsedRealtime.
Refactored init/utils/boot_clock into base/chrono_utils.
Bug: 34352037
Test: none
Change-Id: Ied0c00867336b85922369d7ff37520e3d28fc61e
Diffstat (limited to 'bootstat/bootstat.cpp')
-rw-r--r-- | bootstat/bootstat.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp index c85667e86..322add327 100644 --- a/bootstat/bootstat.cpp +++ b/bootstat/bootstat.cpp @@ -21,6 +21,7 @@ #include <getopt.h> #include <unistd.h> +#include <chrono> #include <cmath> #include <cstddef> #include <cstdio> @@ -31,6 +32,7 @@ #include <vector> #include <android/log.h> +#include <android-base/chrono_utils.h> #include <android-base/logging.h> #include <android-base/parseint.h> #include <android-base/strings.h> @@ -38,7 +40,6 @@ #include "boot_event_record_store.h" #include "histogram_logger.h" -#include "uptime_parser.h" namespace { @@ -247,7 +248,8 @@ void RecordBootComplete() { BootEventRecordStore boot_event_store; BootEventRecordStore::BootEventRecord record; - time_t uptime = bootstat::ParseUptime(); + auto uptime = std::chrono::duration_cast<std::chrono::seconds>( + android::base::boot_clock::now().time_since_epoch()); time_t current_time_utc = time(nullptr); if (boot_event_store.GetBootEvent("last_boot_time_utc", &record)) { @@ -274,22 +276,22 @@ void RecordBootComplete() { // Log the amount of time elapsed until the device is decrypted, which // includes the variable amount of time the user takes to enter the // decryption password. - boot_event_store.AddBootEventWithValue("boot_decryption_complete", uptime); + boot_event_store.AddBootEventWithValue("boot_decryption_complete", uptime.count()); // Subtract the decryption time to normalize the boot cycle timing. - time_t boot_complete = uptime - record.second; + std::chrono::seconds boot_complete = std::chrono::seconds(uptime.count() - record.second); boot_event_store.AddBootEventWithValue(boot_complete_prefix + "_post_decrypt", - boot_complete); + boot_complete.count()); } else { boot_event_store.AddBootEventWithValue(boot_complete_prefix + "_no_encryption", - uptime); + uptime.count()); } // Record the total time from device startup to boot complete, regardless of // encryption state. - boot_event_store.AddBootEventWithValue(boot_complete_prefix, uptime); + boot_event_store.AddBootEventWithValue(boot_complete_prefix, uptime.count()); RecordInitBootTimeProp(&boot_event_store, "ro.boottime.init"); RecordInitBootTimeProp(&boot_event_store, "ro.boottime.init.selinux"); |