diff options
author | Tim Barron <tjbarron@google.com> | 2020-12-29 00:23:52 +0000 |
---|---|---|
committer | Tim Barron <tjbarron@google.com> | 2021-01-05 19:03:14 +0000 |
commit | 59c2caa38fd8dca3760dad751f4f8e5de8be25f5 (patch) | |
tree | 28b5f15e8bbfb73eb7470bef37f554ea4f4847a7 /icing/util/clock.h | |
parent | 282a5708af10879b12a09a59ad5bbfa253b1e92a (diff) | |
download | icing-59c2caa38fd8dca3760dad751f4f8e5de8be25f5.tar.gz |
Update Icing from upstream.
Change-Id: Iff50aebffb83529b0454e7c3a6dc6864e7a85f4a
Diffstat (limited to 'icing/util/clock.h')
-rw-r--r-- | icing/util/clock.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/icing/util/clock.h b/icing/util/clock.h index 06f1c9d..2bb7818 100644 --- a/icing/util/clock.h +++ b/icing/util/clock.h @@ -36,17 +36,22 @@ int64_t GetSteadyTimeMilliseconds(); class Timer { public: // Creates and starts the timer. - Timer() : start_timestamp_milliseconds_(GetSteadyTimeMilliseconds()) {} + Timer() : start_timestamp_nanoseconds_(GetSteadyTimeNanoseconds()) {} virtual ~Timer() = default; // Returns the elapsed time from when timer started. virtual int64_t GetElapsedMilliseconds() { - return GetSteadyTimeMilliseconds() - start_timestamp_milliseconds_; + return GetElapsedNanoseconds() / 1000000; + } + + // Returns the elapsed time from when timer started. + virtual int64_t GetElapsedNanoseconds() { + return GetSteadyTimeNanoseconds() - start_timestamp_nanoseconds_; } private: - int64_t start_timestamp_milliseconds_; + int64_t start_timestamp_nanoseconds_; }; // Wrapper around real-time clock functions. This is separated primarily so |