summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp18
-rw-r--r--fastos/src/vespa/fastos/timestamp.h18
-rw-r--r--searchcore/src/tests/proton/common/cachedselect_test.cpp2
3 files changed, 25 insertions, 13 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index bc865448e5a..553d44ac59b 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -46,4 +46,22 @@ time_t time() {
return system_clock::to_time_t(system_clock::now());
}
+namespace {
+
+TimeStamp steady_now() {
+ return duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
+}
+
+}
+void
+StopWatch::start() {
+ _startTime = steady_now();
+ _stopTime = _startTime;
+}
+
+void
+StopWatch::stop() {
+ _stopTime = steady_now();
+}
+
}
diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h
index fd46d200b52..6df83457258 100644
--- a/fastos/src/vespa/fastos/timestamp.h
+++ b/fastos/src/vespa/fastos/timestamp.h
@@ -59,23 +59,21 @@ class ClockSystem
{
public:
static int64_t now();
- static int64_t adjustTick2Sec(int64_t tick) { return tick; }
};
-template <typename ClockT>
-class StopWatchT : public ClockT
+class StopWatch
{
public:
- StopWatchT(void) : _startTime(), _stopTime() { }
+ StopWatch() : _startTime(), _stopTime() { }
- void start() { _startTime = this->now(); _stopTime = _startTime; }
- void stop() { _stopTime = this->now(); }
+ void start();
+ void stop();
- TimeStamp startTime() const { return this->adjustTick2Sec(_startTime); }
+ TimeStamp startTime() const { return _startTime; }
TimeStamp elapsed() const {
TimeStamp diff(_stopTime - _startTime);
- return this->adjustTick2Sec((diff > 0) ? diff : TimeStamp(0));
+ return (diff > 0) ? diff : TimeStamp(0);
}
private:
TimeStamp _startTime;
@@ -84,9 +82,5 @@ private:
time_t time();
-
-typedef StopWatchT<ClockSystem> TickStopWatch;
-typedef TickStopWatch StopWatch;
-
}
diff --git a/searchcore/src/tests/proton/common/cachedselect_test.cpp b/searchcore/src/tests/proton/common/cachedselect_test.cpp
index df414439bce..bb4d7063183 100644
--- a/searchcore/src/tests/proton/common/cachedselect_test.cpp
+++ b/searchcore/src/tests/proton/common/cachedselect_test.cpp
@@ -617,7 +617,7 @@ TEST_F("Test performance when using attributes", TestFixture)
uint32_t i;
const uint32_t loopcnt = 30000;
LOG(info, "Starting minibm loop, %u ierations of 4 docs each", loopcnt);
- fastos::StopWatchT<fastos::ClockSystem> sw;
+ fastos::StopWatch sw;
sw.start();
for (i = 0; i < loopcnt; ++i) {
ctx._docId = 1u;