diff options
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/tests/atomic/atomic_bench.cpp | 1 | ||||
-rw-r--r-- | vespalib/src/tests/atomic/atomic_test.cpp | 6 | ||||
-rw-r--r-- | vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp | 12 | ||||
-rw-r--r-- | vespalib/src/tests/delegatelist/delegatelist.cpp | 5 | ||||
-rw-r--r-- | vespalib/src/tests/time/time_box_test.cpp | 6 |
5 files changed, 15 insertions, 15 deletions
diff --git a/vespalib/src/tests/atomic/atomic_bench.cpp b/vespalib/src/tests/atomic/atomic_bench.cpp index 003ef25ba45..6294f956507 100644 --- a/vespalib/src/tests/atomic/atomic_bench.cpp +++ b/vespalib/src/tests/atomic/atomic_bench.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/atomic.h> +#include <vespa/fastos/thread.h> #include <vector> #include <algorithm> #include <sstream> diff --git a/vespalib/src/tests/atomic/atomic_test.cpp b/vespalib/src/tests/atomic/atomic_test.cpp index 1133d9b51bd..09fc99edeb9 100644 --- a/vespalib/src/tests/atomic/atomic_test.cpp +++ b/vespalib/src/tests/atomic/atomic_test.cpp @@ -1,12 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("atomic_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/atomic.h> +#include <vespa/fastos/thread.h> #include <vector> #include <algorithm> #include <sstream> +#include <vespa/log/log.h> +LOG_SETUP("atomic_test"); class Test : public vespalib::TestApp { diff --git a/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp b/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp index b0cd577cc66..ac6a57358d6 100644 --- a/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp +++ b/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp @@ -8,7 +8,7 @@ TEST("require that the benchmark timer can be used as advertised") { BenchmarkTimer timer(1.0); while (timer.has_budget()) { timer.before(); - FastOS_Thread::Sleep(5); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); timer.after(); } EXPECT_TRUE(timer.min_time() >= 0.0); @@ -17,15 +17,15 @@ TEST("require that the benchmark timer can be used as advertised") { TEST("require that the benchmark timer all-in-one benchmarking works") { uint32_t sleep_time = 5; - double t = BenchmarkTimer::benchmark([sleep_time](){FastOS_Thread::Sleep(sleep_time);}, 1.0); + double t = BenchmarkTimer::benchmark([sleep_time](){std::this_thread::sleep_for(std::chrono::milliseconds(sleep_time));}, 1.0); fprintf(stderr, "5 ms sleep takes: %g ms\n", t * 1000.0); } TEST("require that the benchmark timer all-in-one benchmarking with baseline works") { uint32_t work_time = 10; uint32_t baseline_time = 5; - double t = BenchmarkTimer::benchmark([&](){FastOS_Thread::Sleep(work_time);}, - [&](){FastOS_Thread::Sleep(baseline_time);}, 1.0); + double t = BenchmarkTimer::benchmark([&](){std::this_thread::sleep_for(std::chrono::milliseconds(work_time));}, + [&](){std::this_thread::sleep_for(std::chrono::milliseconds(baseline_time));}, 1.0); fprintf(stderr, "10 ms sleep - 5 ms sleep takes: %g ms\n", t * 1000.0); } @@ -33,8 +33,8 @@ TEST("require that the benchmark timer all-in-one benchmarking with baseline and uint32_t work_time = 2; uint32_t baseline_time = 1; uint32_t loop_cnt = 0; - double t = BenchmarkTimer::benchmark([&](){FastOS_Thread::Sleep(work_time); ++loop_cnt;}, - [&](){FastOS_Thread::Sleep(baseline_time);}, 7, 0.0); + double t = BenchmarkTimer::benchmark([&](){std::this_thread::sleep_for(std::chrono::milliseconds(work_time)); ++loop_cnt;}, + [&](){std::this_thread::sleep_for(std::chrono::milliseconds(baseline_time));}, 7, 0.0); EXPECT_EQUAL(loop_cnt, 7u); fprintf(stderr, "2 ms sleep - 1 ms sleep takes: %g ms\n", t * 1000.0); } diff --git a/vespalib/src/tests/delegatelist/delegatelist.cpp b/vespalib/src/tests/delegatelist/delegatelist.cpp index 11dd4d7d9e2..6a9751440a6 100644 --- a/vespalib/src/tests/delegatelist/delegatelist.cpp +++ b/vespalib/src/tests/delegatelist/delegatelist.cpp @@ -3,10 +3,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/delegatelist.hpp> #include <vespa/vespalib/util/guard.h> - -#include <memory> -#include <algorithm> -#include <vector> +#include <vespa/fastos/thread.h> #include <queue> #include <vespa/log/log.h> diff --git a/vespalib/src/tests/time/time_box_test.cpp b/vespalib/src/tests/time/time_box_test.cpp index 478d749e15d..32cf1eb66b3 100644 --- a/vespalib/src/tests/time/time_box_test.cpp +++ b/vespalib/src/tests/time/time_box_test.cpp @@ -10,13 +10,13 @@ TEST("require that long-lived timebox returns falling time left numbers") { double timeLeft = box.timeLeft(); EXPECT_TRUE(timeLeft <= last_timeLeft); last_timeLeft = timeLeft; - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } TEST("require that short-lived timebox times out") { vespalib::TimeBox box(0.125); - FastOS_Thread::Sleep(150); + std::this_thread::sleep_for(std::chrono::milliseconds(150)); EXPECT_FALSE(box.hasTimeLeft()); EXPECT_EQUAL(box.timeLeft(), 0.0); } @@ -27,7 +27,7 @@ TEST("require that short-lived timebox always returns at least minimum time") { double timeLeft = box.timeLeft(); EXPECT_TRUE(timeLeft <= 0.250); EXPECT_TRUE(timeLeft >= 0.125); - FastOS_Thread::Sleep(30); + std::this_thread::sleep_for(std::chrono::milliseconds(30)); } EXPECT_FALSE(box.hasTimeLeft()); EXPECT_EQUAL(box.timeLeft(), 0.125); |