summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-19 23:22:55 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-20 21:55:01 +0000
commitcf3b20dba22718b533eac6854cde86b6538958af (patch)
tree9a0e795cd74d2721140c48012f794298dfef7420 /vespalib
parent64b7c822099d7cda921699e380c4d95608a1ab00 (diff)
FastOS_Time -> std::chrono.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/executor/stress_test.cpp26
-rw-r--r--vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp8
-rw-r--r--vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp7
-rw-r--r--vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp14
4 files changed, 24 insertions, 31 deletions
diff --git a/vespalib/src/tests/executor/stress_test.cpp b/vespalib/src/tests/executor/stress_test.cpp
index 702991fd779..bbe754be2bd 100644
--- a/vespalib/src/tests/executor/stress_test.cpp
+++ b/vespalib/src/tests/executor/stress_test.cpp
@@ -4,7 +4,7 @@
#include <vespa/vespalib/util/executor.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/locale/c.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
using namespace vespalib;
using namespace std::literals;
@@ -60,29 +60,28 @@ uint32_t
Test::calibrate(double wanted_ms)
{
uint32_t n = 0;
- FastOS_Time t0;
- FastOS_Time t1;
+ fastos::StopWatch t0;
+ fastos::StopWatch t1;
{ // calibration of calibration loop
uint32_t result = 0;
- t0.SetNow();
double ms;
do {
result += doStuff(++n);
- t1.SetNow();
- ms = (t1.MilliSecs() - t0.MilliSecs());
+ t1.restart();
+ ms = (t1.elapsed().ms() - t0.elapsed().ms());
} while (ms < 1000.0);
_result += result;
}
{ // calibrate loop
- t0.SetNow();
+ t0.restart();
uint32_t result = 0;
for (uint32_t i = 0; i < n; ++i) {
result += doStuff(i);
}
_result += result;
- t1.SetNow();
+ t1.restart();
}
- double ms = (t1.MilliSecs() - t0.MilliSecs());
+ double ms = (t1.elapsed().ms() - t0.elapsed().ms());
double size = (((double)n) / ms) * wanted_ms;
return (uint32_t) std::round(size);
}
@@ -122,22 +121,19 @@ Test::Main()
fprintf(stderr, "all threads have been accounted for...\n");
}
{
- FastOS_Time t0;
- FastOS_Time t1;
+ fastos::StopWatch t0;
fprintf(stderr, "starting task submission...\n");
- t0.SetNow();
uint32_t result = 0;
for (uint32_t i = 0; i < tasks; ++i) {
Executor::Task::UP t(new CPUTask(taskSize, result));
t = executor.execute(std::move(t));
- while (t.get() != 0) {
+ while (t) {
std::this_thread::sleep_for(10ms);
t = executor.execute(std::move(t));
}
}
executor.sync();
- t1.SetNow();
- double ms = (t1.MilliSecs() - t0.MilliSecs());
+ double ms = t0.elapsed().ms();
fprintf(stderr, "total execution wall time: %g ms\n", ms);
_result += result;
}
diff --git a/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp b/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp
index e6fdab7d773..c43d0ec1c29 100644
--- a/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp
+++ b/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp
@@ -3,7 +3,7 @@
#include <vespa/vespalib/util/left_right_heap.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/inline.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
using namespace vespalib;
@@ -36,11 +36,11 @@ struct MyInvCmp {
struct Timer {
double minTime;
- FastOS_Time timer;
+ fastos::StopWatch timer;
Timer() : minTime(1.0e10), timer() {}
- void start() { timer.SetNow(); }
+ void start() { timer.restart(); }
void stop() {
- double ms = timer.MilliSecsToNow();
+ double ms = timer.elapsed().ms();
minTime = std::min(minTime, ms);
}
};
diff --git a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp
index b113e7a2284..5b6df6eef4e 100644
--- a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp
+++ b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp
@@ -2,7 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/simple_thread_bundle.h>
#include <vespa/vespalib/util/box.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
using namespace vespalib;
@@ -57,12 +57,11 @@ TEST("estimate cost of thread bundle fork/join") {
}
double minTime = 1000000.0;
for (size_t samples = 0; samples < 32; ++samples) {
- FastOS_Time t;
- t.SetNow();
+ fastos::StopWatch timer;
for (size_t n = 0; n < fork; ++n) {
threadBundle.run(targets);
}
- double time = t.MilliSecsToNow();
+ double time = timer.elapsed().ms();
if (time < minTime) {
minTime = time;
}
diff --git a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp
index 2a58f1df382..61ba2593eb3 100644
--- a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp
+++ b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp
@@ -2,7 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/data/slime/slime.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
using namespace vespalib;
using namespace vespalib::slime::convenience;
@@ -22,7 +22,7 @@ struct MyBuffer : public Output {
}
};
-MyBuffer::~MyBuffer() { }
+MyBuffer::~MyBuffer() = default;
std::string make_name(size_t idx) {
return make_string("summary_feature_%zu", idx);
@@ -47,13 +47,12 @@ TEST_F("slime -> json speed", FeatureFixture()) {
double minTime = 1000000.0;
MyBuffer buffer;
for (size_t i = 0; i < 16; ++i) {
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
for (size_t j = 0; j < 256; ++j) {
buffer.used = 0;
slime::JsonFormat::encode(f1.slime, buffer, true);
}
- minTime = std::min(minTime, timer.MilliSecsToNow() / 256.0);
+ minTime = std::min(minTime, timer.elapsed().ms() / 256.0);
size = buffer.used;
}
fprintf(stderr, "time: %g ms (size: %zu bytes)\n", minTime, size);
@@ -64,13 +63,12 @@ TEST_F("slime -> binary speed", FeatureFixture()) {
double minTime = 1000000.0;
MyBuffer buffer;
for (size_t i = 0; i < 16; ++i) {
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
for (size_t j = 0; j < 256; ++j) {
buffer.used = 0;
slime::BinaryFormat::encode(f1.slime, buffer);
}
- minTime = std::min(minTime, timer.MilliSecsToNow() / 256.0);
+ minTime = std::min(minTime, timer.elapsed().ms() / 256.0);
size = buffer.used;
}
fprintf(stderr, "time: %g ms (size: %zu bytes)\n", minTime, size);