diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-19 15:54:28 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-20 10:16:59 +0000 |
commit | 1776164d76a34d81e887924c372be4c5b3cddc2a (patch) | |
tree | 2bc98d5fb22653eb259b4656f5215ecd8cdd2a81 /fastos | |
parent | d328b6ce8389fb12c76d813476fff925c452c1cb (diff) |
Address comment by specifying timeunit in the type.
Diffstat (limited to 'fastos')
-rw-r--r-- | fastos/src/vespa/fastos/timestamp.cpp | 12 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/timestamp.h | 9 |
2 files changed, 6 insertions, 15 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp index 5daad63f698..c7f269b59b9 100644 --- a/fastos/src/vespa/fastos/timestamp.cpp +++ b/fastos/src/vespa/fastos/timestamp.cpp @@ -87,20 +87,18 @@ SteadyTimeStamp::toUTC() const { } StopWatch::StopWatch() - : _startTime(steady_now()), - _stopTime(_startTime) + : _startTime(steady_now()) { } void StopWatch::restart() { _startTime = steady_now(); - _stopTime = _startTime; } -StopWatch & -StopWatch::stop() { - _stopTime = steady_now(); - return *this; +TimeStamp +StopWatch::elapsed() const { + TimeStamp diff(steady_now() - _startTime); + return (diff > 0) ? diff : TimeStamp(0); } void diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h index 36f296b891f..79d6ef5eed6 100644 --- a/fastos/src/vespa/fastos/timestamp.h +++ b/fastos/src/vespa/fastos/timestamp.h @@ -151,18 +151,11 @@ class StopWatch { public: StopWatch(); - - StopWatch & stop(); void restart(); - - TimeStamp elapsed() const { - TimeStamp diff(_stopTime - _startTime); - return (diff > 0) ? diff : TimeStamp(0); - } + TimeStamp elapsed() const; static void waitAtLeast(std::chrono::microseconds us, bool busyWait); private: SteadyTimeStamp _startTime; - SteadyTimeStamp _stopTime; }; time_t time(); |