aboutsummaryrefslogtreecommitdiffstats
path: root/fastos/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-09 04:09:05 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-16 23:48:46 +0000
commit225be01d5405c179584eb7fc08309c8f4a08fb22 (patch)
treefe50a91214b2db66a0df797d2dc46e51ab4bfcd1 /fastos/src/tests
parentc72bdc628b4493bfb2974ab3fe479d2af0d376f1 (diff)
GC unused timestamp in schema.
Diffstat (limited to 'fastos/src/tests')
-rw-r--r--fastos/src/tests/processtest.cpp12
-rw-r--r--fastos/src/tests/thread_bounce_test.cpp13
-rw-r--r--fastos/src/tests/threadtest.cpp25
3 files changed, 28 insertions, 22 deletions
diff --git a/fastos/src/tests/processtest.cpp b/fastos/src/tests/processtest.cpp
index 5a78eff1d36..e39b6461a29 100644
--- a/fastos/src/tests/processtest.cpp
+++ b/fastos/src/tests/processtest.cpp
@@ -1,9 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "tests.h"
#include <vespa/fastos/process.h>
-#include <vespa/fastos/timestamp.h>
using namespace std::chrono_literals;
+using namespace std::chrono;
class MyListener : public FastOS_ProcessRedirectListener
{
@@ -213,7 +213,7 @@ public:
if(waitKill)
timeOut = 1;
- fastos::StopWatch timer;
+ steady_clock::time_point start = steady_clock::now();
int returnCode;
if(!xproc->Wait(&returnCode, timeOut))
@@ -228,11 +228,11 @@ public:
}
if (waitKill) {
- double milliSecs = timer.elapsed().ms();
- if((milliSecs < 900) ||
- (milliSecs > 3500))
+ nanoseconds elapsed = steady_clock::now() - start;
+ if((elapsed < 900ms) ||
+ (elapsed > 3500ms))
{
- Progress(false, "WaitKill time = %d", int(milliSecs));
+ Progress(false, "WaitKill time = %d", duration_cast<milliseconds>(elapsed).count());
}
}
diff --git a/fastos/src/tests/thread_bounce_test.cpp b/fastos/src/tests/thread_bounce_test.cpp
index 84506938455..488002341e9 100644
--- a/fastos/src/tests/thread_bounce_test.cpp
+++ b/fastos/src/tests/thread_bounce_test.cpp
@@ -3,7 +3,8 @@
#include "tests.h"
#include "job.h"
#include "thread_test_base.hpp"
-#include <vespa/fastos/timestamp.h>
+
+using namespace std::chrono;
class Thread_Bounce_Test : public ThreadTestBase
{
@@ -39,12 +40,12 @@ class Thread_Bounce_Test : public ThreadTestBase
lastcntsum = -1;
for (int iter = 0; iter < 8; iter++) {
- fastos::StopWatch checkTime;
+ steady_clock::time_point start = steady_clock::now();
- int left = static_cast<int>(checkTime.elapsed().ms());
- while (left < 1000) {
- std::this_thread::sleep_for(std::chrono::milliseconds(1000 - left));
- left = static_cast<int>(checkTime.elapsed().ms());
+ nanoseconds left = steady_clock::now() - start;
+ while (left < 1000ms) {
+ std::this_thread::sleep_for(1000ms - left);
+ left = steady_clock::now() - start;
}
mutex1.lock();
diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp
index 0a8a0d2bf02..1fa9820c8d7 100644
--- a/fastos/src/tests/threadtest.cpp
+++ b/fastos/src/tests/threadtest.cpp
@@ -3,13 +3,15 @@
#include "tests.h"
#include "job.h"
#include "thread_test_base.hpp"
-#include <vespa/fastos/timestamp.h>
#include <cstdlib>
#include <chrono>
#define MUTEX_TEST_THREADS 6
#define MAX_THREADS 7
+using namespace std::chrono;
+using namespace std::chrono_literals;
+
class ThreadTest : public ThreadTestBase
{
int Main () override;
@@ -202,7 +204,7 @@ class ThreadTest : public ThreadTestBase
Job *jobs = new Job[count];
threadsok = 0;
- fastos::StopWatch timer;
+ steady_clock::time_point start = steady_clock::now();
for (i = 0; i < count; i++) {
jobs[i].code = SILENTNOP;
jobs[i].ownThread = pool->NewThread(this, &jobs[i]);
@@ -225,13 +227,13 @@ class ThreadTest : public ThreadTestBase
if (jobs[i].ownThread != nullptr)
jobs[i].ownThread->Join();
}
- fastos::TimeStamp used = timer.elapsed();
+ nanoseconds used = steady_clock::now() - start;
if (!silent) {
- Progress(true, "Used time: %2.3f", used.sec());
+ double timeused = used.count() / 1000000000.0;
- double timeused = used.sec();
- ProgressFloat(true, "Threads/s: %6.1f",
+ Progress(true, "Used time: %2.3f", timeused);
+ ProgressFloat(true, "Threads/s: %6.1f",
static_cast<float>(static_cast<double>(threadsok) / timeused));
}
if (threadsok != ((outercount + 1) * count))
@@ -517,12 +519,13 @@ class ThreadTest : public ThreadTestBase
std::mutex **mutexes = new std::mutex*[allocCount];
- fastos::StopWatch timer;
+ steady_clock::time_point start = steady_clock::now();
for (i=0; i<allocCount; i++)
mutexes[i] = new std::mutex;
- Progress(true, "Allocated %d mutexes at time: %ld ms", allocCount, timer.elapsed().ms());
+ nanoseconds elapsed = steady_clock::now() - start;
+ Progress(true, "Allocated %d mutexes at time: %ld ms", allocCount, duration_cast<milliseconds>(elapsed).count());
for (int e=0; e<4; e++) {
for(i=0; i<allocCount; i++)
@@ -531,12 +534,14 @@ class ThreadTest : public ThreadTestBase
for(i=0; i<allocCount; i++)
mutexes[i]->unlock();
- Progress(true, "Tested %d mutexes at time: %d ms", allocCount, timer.elapsed().ms());
+ elapsed = steady_clock::now() - start;
+ Progress(true, "Tested %d mutexes at time: %d ms", allocCount, duration_cast<milliseconds>(elapsed).count());
}
for (i=0; i<allocCount; i++)
delete mutexes[i];
- Progress(true, "Deleted %d mutexes at time: %d ms", allocCount, timer.elapsed().ms());
+ elapsed = steady_clock::now() - start;
+ Progress(true, "Deleted %d mutexes at time: %d ms", allocCount, duration_cast<milliseconds>(elapsed).count());
delete [] mutexes;