diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-15 09:42:09 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-15 09:42:09 +0000 |
commit | d817a7407ee9cef2684a9777a0b5d33c6b35a5f3 (patch) | |
tree | a9931a75cfd117c429a197ecb2470f5138c90e72 /fastos/src | |
parent | a3a13616e52c4ac3c97b572c81e485bb0f81295b (diff) |
Use steady_clock
Diffstat (limited to 'fastos/src')
-rw-r--r-- | fastos/src/vespa/fastos/timestamp.cpp | 16 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/timestamp.h | 6 |
2 files changed, 19 insertions, 3 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp index 553d44ac59b..8f8480d09ab 100644 --- a/fastos/src/vespa/fastos/timestamp.cpp +++ b/fastos/src/vespa/fastos/timestamp.cpp @@ -32,7 +32,8 @@ TimeStamp::asString(double timeInSeconds) return std::string(retval); } -int64_t ClockSystem::now() +int64_t +ClockSystem::now() { struct timeval timeNow; gettimeofday(&timeNow, nullptr); @@ -42,17 +43,26 @@ int64_t ClockSystem::now() return ns; } -time_t time() { +time_t +time() { return system_clock::to_time_t(system_clock::now()); } namespace { -TimeStamp steady_now() { +int64_t +steady_now() { return duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count(); } } + +int64_t +ClockSteady::now() +{ + return steady_now(); +} + void StopWatch::start() { _startTime = steady_now(); diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h index 6df83457258..21ef9d6df75 100644 --- a/fastos/src/vespa/fastos/timestamp.h +++ b/fastos/src/vespa/fastos/timestamp.h @@ -61,6 +61,12 @@ public: static int64_t now(); }; +class ClockSteady +{ +public: + static int64_t now(); +}; + class StopWatch { public: |