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 /init/util.h | |
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 'init/util.h')
-rw-r--r-- | init/util.h | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/init/util.h b/init/util.h index 5c38dc3c9..4444427ea 100644 --- a/init/util.h +++ b/init/util.h @@ -25,6 +25,8 @@ #include <ostream> #include <string> +#include <android-base/chrono_utils.h> + #define COLDBOOT_DONE "/dev/.coldboot_done" using namespace std::chrono_literals; @@ -35,32 +37,16 @@ int create_socket(const char *name, int type, mode_t perm, bool read_file(const char* path, std::string* content); bool write_file(const char* path, const char* content); -// A std::chrono clock based on CLOCK_BOOTTIME. -class boot_clock { - public: - typedef std::chrono::nanoseconds duration; - typedef std::chrono::time_point<boot_clock, duration> time_point; - static constexpr bool is_steady = true; - - static time_point now(); -}; - class Timer { public: - Timer() : start_(boot_clock::now()) { - } + Timer(); - double duration_s() const { - typedef std::chrono::duration<double> double_duration; - return std::chrono::duration_cast<double_duration>(boot_clock::now() - start_).count(); - } + double duration_s() const; - int64_t duration_ms() const { - return std::chrono::duration_cast<std::chrono::milliseconds>(boot_clock::now() - start_).count(); - } + int64_t duration_ms() const; private: - boot_clock::time_point start_; + android::base::boot_clock::time_point start_; }; std::ostream& operator<<(std::ostream& os, const Timer& t); |