diff options
-rw-r--r-- | searchlib/src/tests/engine/searchapi/searchapi_test.cpp | 8 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/engine/trace.cpp | 4 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/engine/trace.h | 12 |
3 files changed, 13 insertions, 11 deletions
diff --git a/searchlib/src/tests/engine/searchapi/searchapi_test.cpp b/searchlib/src/tests/engine/searchapi/searchapi_test.cpp index 297a45f5b22..848aa91553d 100644 --- a/searchlib/src/tests/engine/searchapi/searchapi_test.cpp +++ b/searchlib/src/tests/engine/searchapi/searchapi_test.cpp @@ -235,7 +235,7 @@ void verify(vespalib::stringref expected, const vespalib::Slime & slime) { } TEST("verify trace") { - RelativeTime clock(std::make_unique<CountingClock>(7)); + RelativeTime clock(std::make_unique<CountingClock>(7, 1700000)); Trace t(clock); verify("{" " traces: [" @@ -248,7 +248,7 @@ TEST("verify trace") { " traces: [" " {" " tag: 'tag_a'," - " time: 1" + " time_ms: 1.7" " }" " ]," " creation_time: 7" @@ -260,11 +260,11 @@ TEST("verify trace") { " traces: [" " {" " tag: 'tag_a'," - " time: 1" + " time_ms: 1.7" " }," " {" " tag: 'tag_b'," - " time: 2," + " time_ms: 3.4," " long: 19" " }" " ]," diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp index 938d588f658..e119a49bce2 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.cpp +++ b/searchlib/src/vespa/searchlib/engine/trace.cpp @@ -26,7 +26,7 @@ Trace::Cursor & Trace::createCursor(vespalib::stringref name) { Cursor & trace = _traces.addObject(); trace.setString("tag", name); - trace.setLong("time", _relativeTime.timeSinceDawn()); + trace.setDouble("time_ms", _relativeTime.timeSinceDawn()/1000000.0); return trace; } @@ -36,7 +36,7 @@ Trace::addEvent(uint32_t level, vespalib::stringref event) { Cursor & trace = _traces.addObject(); trace.setString("event", event); - trace.setLong("time", _relativeTime.timeSinceDawn()); + trace.setDouble("time_ms", _relativeTime.timeSinceDawn()/1000000.0); } vespalib::string diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h index c9052401f74..6c59047221f 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.h +++ b/searchlib/src/vespa/searchlib/engine/trace.h @@ -14,21 +14,23 @@ class Clock { public: virtual ~Clock() = default; virtual fastos::TimeStamp now() const = 0; - virtual Clock * clone() const = 0; }; class FastosClock : public Clock { public: fastos::TimeStamp now() const override { return fastos::ClockSystem::now(); } - FastosClock * clone() const override { return new FastosClock(*this); } }; class CountingClock : public Clock { public: - CountingClock(int64_t start) : _nextTime(start) { } - fastos::TimeStamp now() const override { return _nextTime++; } - CountingClock * clone() const override { return new CountingClock(*this); } + CountingClock(int64_t start, int64_t increment) : _increment(increment), _nextTime(start) { } + fastos::TimeStamp now() const override { + int64_t prev = _nextTime; + _nextTime += _increment; + return prev; + } private: + const int64_t _increment; mutable int64_t _nextTime; }; |