summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-03-11 07:45:50 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-03-11 07:45:50 +0000
commit9821a7fd7de84ee0dbae255ffff480c43135fcd0 (patch)
tree0c67cbed7587d3d55243573408ab0543476727f2 /searchlib
parenta3dcd03d92e1989b0ccc0dc1aaf659c86531fd85 (diff)
Milliseconds is the better unit here.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/engine/searchapi/searchapi_test.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.h12
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;
};