summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-20 09:47:17 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-20 21:55:01 +0000
commitdae2799f522bf973d4baa99abd04bd3fbe3454a5 (patch)
tree8cbe405840965be88101010149ba92b24f837267 /fastos
parentcf3b20dba22718b533eac6854cde86b6538958af (diff)
Remove more usage of FastOS_Time
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/tests/CMakeLists.txt14
-rw-r--r--fastos/src/tests/processtest.cpp45
-rw-r--r--fastos/src/tests/thread_bounce_test.cpp9
-rw-r--r--fastos/src/tests/threadtest.cpp47
-rw-r--r--fastos/src/tests/timetest.cpp296
-rw-r--r--fastos/src/tests/typetest.cpp4
-rw-r--r--fastos/src/tests/usecputest.cpp69
-rw-r--r--fastos/src/vespa/fastos/unix_process.cpp13
8 files changed, 35 insertions, 462 deletions
diff --git a/fastos/src/tests/CMakeLists.txt b/fastos/src/tests/CMakeLists.txt
index 87d56a56154..cc4928cc7d0 100644
--- a/fastos/src/tests/CMakeLists.txt
+++ b/fastos/src/tests/CMakeLists.txt
@@ -61,13 +61,6 @@ vespa_add_executable(fastos_backtracetest_app TEST
fastos
)
vespa_add_test(NAME fastos_backtracetest_app NO_VALGRIND COMMAND fastos_backtracetest_app)
-vespa_add_executable(fastos_timetest_app TEST
- SOURCES
- timetest.cpp
- DEPENDS
- fastos
-)
-vespa_add_test(NAME fastos_timetest_app NO_VALGRIND COMMAND fastos_timetest_app)
vespa_add_executable(fastos_typetest_app TEST
SOURCES
typetest.cpp
@@ -75,10 +68,3 @@ vespa_add_executable(fastos_typetest_app TEST
fastos
)
vespa_add_test(NAME fastos_typetest_app NO_VALGRIND COMMAND fastos_typetest_app)
-vespa_add_executable(fastos_usecputest_app TEST
- SOURCES
- usecputest.cpp
- DEPENDS
- fastos
-)
-vespa_add_test(NAME fastos_usecputest_app NO_VALGRIND COMMAND fastos_usecputest_app)
diff --git a/fastos/src/tests/processtest.cpp b/fastos/src/tests/processtest.cpp
index cd6839fd0aa..846e1fbbc9f 100644
--- a/fastos/src/tests/processtest.cpp
+++ b/fastos/src/tests/processtest.cpp
@@ -1,7 +1,7 @@
// 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/time.h>
+#include <vespa/fastos/timestamp.h>
#include <vespa/fastos/file.h>
class MyListener : public FastOS_ProcessRedirectListener
@@ -78,27 +78,19 @@ public:
{
}
- void Run (FastOS_ThreadInterface *thisThread, void *arg) override
+ void Run (FastOS_ThreadInterface *, void *) override
{
- (void)thisThread;
- (void)arg;
- FastOS_Time startTime, endTime;
- startTime.SetNow();
+ fastos::StopWatch timer;
FastOS_Process xproc(_processCmdLine);
int returnCode = -1;
- if(xproc.Create())
- {
+ if (xproc.Create()) {
xproc.Wait(&returnCode);
}
- endTime.SetNow();
-
- endTime -= startTime;
-
- _timeSpent = int(endTime.MilliSecs());
+ _timeSpent = int(timer.elapsed().ms());
}
int GetTimeSpent ()
@@ -135,8 +127,7 @@ public:
{
// printf("Data: [%s]\n", static_cast<const char *>(data));
- if(length == 5)
- {
+ if(length == 5) {
const char *dataMatch = "IPCM";
if(!_isChild)
dataMatch = "IPCR";
@@ -289,8 +280,7 @@ public:
if(waitKill)
timeOut = 1;
- FastOS_Time timeBeforeWait;
- timeBeforeWait.SetNow();
+ fastos::StopWatch timer;
int returnCode;
if(!xproc->Wait(&returnCode, timeOut))
@@ -304,13 +294,8 @@ public:
Progress(false, "returnCode = %d", returnCode);
}
- if(waitKill)
- {
- FastOS_Time waitTime;
- waitTime.SetNow();
-
- waitTime -= timeBeforeWait;
- double milliSecs = waitTime.MilliSecs();
+ if (waitKill) {
+ double milliSecs = timer.elapsed().ms();
if((milliSecs < 900) ||
(milliSecs > 3500))
{
@@ -334,8 +319,7 @@ public:
Progress(MyListener::_allocCount == 0, "MyListener alloc count = %d",
MyListener::_allocCount);
- if(!doKill && !waitKill)
- {
+ if (!doKill && !waitKill) {
Progress(MyListener::_successCount == (2 * numLoops * numEachTime),
"MyListener _successCount = %d", MyListener::_successCount);
@@ -349,12 +333,10 @@ public:
PrintSeparator();
}
- int DoChildRole ()
- {
+ int DoChildRole () {
int rc = 124;
int i;
- for(i=0; i<(20*10); i++)
- {
+ for(i=0; i<(20*10); i++) {
if(_gotMessage)
break;
@@ -373,8 +355,7 @@ public:
return rc;
}
- void IPCTest ()
- {
+ void IPCTest () {
TestHeader ("IPC Test");
const char *childProgram = _argv[1];
diff --git a/fastos/src/tests/thread_bounce_test.cpp b/fastos/src/tests/thread_bounce_test.cpp
index 423221d55cb..f7bb7ee1260 100644
--- a/fastos/src/tests/thread_bounce_test.cpp
+++ b/fastos/src/tests/thread_bounce_test.cpp
@@ -3,7 +3,7 @@
#include "tests.h"
#include "job.h"
#include "thread_test_base.hpp"
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
class Thread_Bounce_Test : public ThreadTestBase
{
@@ -20,7 +20,6 @@ class Thread_Bounce_Test : public ThreadTestBase
std::condition_variable cond2;
Job job1;
Job job2;
- FastOS_Time checkTime;
int cnt1;
int cnt2;
int cntsum;
@@ -40,12 +39,12 @@ class Thread_Bounce_Test : public ThreadTestBase
lastcntsum = -1;
for (int iter = 0; iter < 8; iter++) {
- checkTime.SetNow();
+ fastos::StopWatch checkTime;
- int left = static_cast<int>(checkTime.MilliSecsToNow());
+ int left = static_cast<int>(checkTime.elapsed().ms());
while (left < 1000) {
FastOS_Thread::Sleep(1000 - left);
- left = static_cast<int>(checkTime.MilliSecsToNow());
+ left = static_cast<int>(checkTime.elapsed().ms());
}
mutex1.lock();
diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp
index b0b64697129..9507bb1e5d7 100644
--- a/fastos/src/tests/threadtest.cpp
+++ b/fastos/src/tests/threadtest.cpp
@@ -3,7 +3,7 @@
#include "tests.h"
#include "job.h"
#include "thread_test_base.hpp"
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
#include <cstdlib>
#include <chrono>
@@ -190,9 +190,6 @@ class ThreadTest : public ThreadTestBase
int j;
bool rc;
int threadsok;
- FastOS_Time starttime;
- FastOS_Time endtime;
- FastOS_Time usedtime;
if (!silent)
TestHeader("Thread Create Performance");
@@ -205,7 +202,7 @@ class ThreadTest : public ThreadTestBase
Job *jobs = new Job[count];
threadsok = 0;
- starttime.SetNow();
+ fastos::StopWatch timer;
for (i = 0; i < count; i++) {
jobs[i].code = SILENTNOP;
jobs[i].ownThread = pool->NewThread(this, &jobs[i]);
@@ -228,19 +225,14 @@ class ThreadTest : public ThreadTestBase
if (jobs[i].ownThread != nullptr)
jobs[i].ownThread->Join();
}
- endtime.SetNow();
- usedtime = endtime;
- usedtime -= starttime;
+ fastos::TimeStamp used = timer.elapsed();
if (!silent) {
- Progress(true, "Used time: %d.%03d",
- usedtime.GetSeconds(), usedtime.GetMicroSeconds() / 1000);
+ Progress(true, "Used time: %2.3f", used.sec());
- double timeused = usedtime.GetSeconds() +
- static_cast<double>(usedtime.GetMicroSeconds()) / 1000000.0;
+ double timeused = used.sec();
ProgressFloat(true, "Threads/s: %6.1f",
- static_cast<float>(static_cast<double>(threadsok) /
- timeused));
+ static_cast<float>(static_cast<double>(threadsok) / timeused));
}
if (threadsok != ((outercount + 1) * count))
Progress(false, "Only started %d of %d threads", threadsok,
@@ -495,12 +487,12 @@ class ThreadTest : public ThreadTestBase
for(i=0; i<allocCount; i++)
{
- std::mutex *mtx = new std::mutex;
+ std::mutex *mtx = new std::mutex;
mtx->lock();
mtx->unlock();
delete mtx;
- if((i % progressIndex) == (progressIndex - 1))
+ if ((i % progressIndex) == (progressIndex - 1))
Progress(true, "Tested %d std::mutex instances", i + 1);
}
@@ -525,35 +517,26 @@ class ThreadTest : public ThreadTestBase
std::mutex **mutexes = new std::mutex*[allocCount];
- FastOS_Time startTime, nowTime;
- startTime.SetNow();
+ fastos::StopWatch timer;
- for(i=0; i<allocCount; i++)
+ for (i=0; i<allocCount; i++)
mutexes[i] = new std::mutex;
- nowTime.SetNow();
- Progress(true, "Allocated %d mutexes at time: %d ms", allocCount,
- static_cast<int>(nowTime.MilliSecs() - startTime.MilliSecs()));
+ Progress(true, "Allocated %d mutexes at time: %ld ms", allocCount, timer.elapsed().ms());
- for(int e=0; e<4; e++)
- {
+ for (int e=0; e<4; e++) {
for(i=0; i<allocCount; i++)
mutexes[i]->lock();
for(i=0; i<allocCount; i++)
mutexes[i]->unlock();
- nowTime.SetNow();
- Progress(true, "Tested %d mutexes at time: %d ms", allocCount,
- static_cast<int>(nowTime.MilliSecs() -
- startTime.MilliSecs()));
+ Progress(true, "Tested %d mutexes at time: %d ms", allocCount, timer.elapsed().ms());
}
- for(i=0; i<allocCount; i++)
+ for (i=0; i<allocCount; i++)
delete mutexes[i];
- nowTime.SetNow();
- Progress(true, "Deleted %d mutexes at time: %d ms", allocCount,
- static_cast<int>(nowTime.MilliSecs() - startTime.MilliSecs()));
+ Progress(true, "Deleted %d mutexes at time: %d ms", allocCount, timer.elapsed().ms());
delete [] mutexes;
diff --git a/fastos/src/tests/timetest.cpp b/fastos/src/tests/timetest.cpp
deleted file mode 100644
index c0c49884fb1..00000000000
--- a/fastos/src/tests/timetest.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-// 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/time.h>
-#include <cmath>
-
-using namespace fastos;
-
-class TimeTest : public BaseTest
-{
-private:
-
-public:
- virtual ~TimeTest() {};
-
- void Wait3SecondsTest ()
- {
- TestHeader("Wait 3 seconds test");
- bool rc=false;
- FastOS_Time before, timing;
-
- Progress(true, "Waiting 3 seconds...");
- before.SetNow();
-
- FastOS_Thread::Sleep(3000);
-
- timing.SetNow();
-
- rc = (timing > before);
- Progress(rc, "AfterTime > BeforeTime");
-
- rc = (before < timing);
- Progress(rc, "BeforeTime < AfterTime");
-
- rc = (before <= timing);
- Progress(rc, "BeforeTime <= AfterTime");
-
- rc = (timing >= before);
- Progress(rc, "AfterTime >= BeforeTime");
-
- rc = (timing >= timing);
- Progress(rc, "AfterTime >= AfterTime");
-
- rc = (timing <= timing);
- Progress(rc, "AfterTime <= AfterTime");
-
- FastOS_Time copyOfAfterTime = timing;
- rc = (copyOfAfterTime == timing);
- Progress(rc, "CopyOfAfterTime == AfterTime");
-
- timing -= before;
-
- double milliseconds = timing.MilliSecs();
- rc = ((milliseconds >= 1900) &&
- (milliseconds <= 10000)); // More than 10 seconds??
-
- Progress(rc, "Waittime = %d milliseconds",
- static_cast<int>(milliseconds));
-
- double microseconds = timing.MicroSecs();
- rc = ((microseconds >= 1900000) &&
- (microseconds <= 10000000)); // More than 10 seconds??
-
- Progress(rc, "Waittime = %d microseconds",
- static_cast<int>(microseconds));
-
- timing += before;
- rc = (copyOfAfterTime == timing);
- Progress(rc, "CopyOfAfterTime == AfterTime (after minus-plus)");
-
- PrintSeparator();
- }
-
- void TimeArithmeticTest ()
- {
- bool rc=false;
-
- TestHeader("Other Time Aritmetic Test");
-
- FastOS_Time time1, time2;
- time1.SetZero();
- time2.SetZero();
-
- rc = (time1 == time2);
- Progress(rc, "Two zero times are equal");
-
- time1.SetMilliSecs(124);
- Progress(long(time1.MilliSecs()) == 124,
- "SetMilliSecs(124) -> MilliSecs(%ld)",
- long(time1.MilliSecs()));
-
- time1.SetMicroSecs(123000);
- Progress(long(time1.MicroSecs()) == 123000,
- "SetMicroSecs(123000) -> MicroSecs(%ld)",
- long(time1.MicroSecs()));
-
- time1.SetMilliSecs(999124);
- Progress(long(time1.MilliSecs()) == 999124,
- "SetMilliSecs(999124) -> MilliSecs(%ld)",
- long(time1.MilliSecs()));
-
- time1.SetMicroSecs(9123000);
- Progress(long(time1.MicroSecs()) == 9123000,
- "SetMicroSecs(9123000) -> MicroSecs(%ld)",
- long(time1.MicroSecs()));
-
- time2 = time1;
- Progress(long(time2.MicroSecs()) == 9123000,
- "[time2 = time1] -> time2.MicroSecs(%ld)",
- long(time2.MicroSecs()));
-
- time2 += time1;
- Progress(long(time2.MicroSecs()) == 9123000*2,
- "[time2 += time1] -> time2.MicroSecs(%ld)",
- long(time2.MicroSecs()));
-
- time2 += time2;
- Progress(long(time2.MicroSecs()) == 9123000*4,
- "[time2 += time2] -> time2.MicroSecs(%ld)",
- long(time2.MicroSecs()));
-
- time2 -= time1;
- Progress(long(time2.MicroSecs()) == 9123000*3,
- "[time2 -= time2] -> time2.MicroSecs(%ld)",
- long(time2.MicroSecs()));
-
- Progress(time2 > time1,
- "[time2 > time2] -> %s", time2 > time1 ? "true" : "false");
- Progress(time2 >= time1,
- "[time2 >= time2] -> %s", time2 >= time1 ? "true" : "false");
- Progress(time1 < time2,
- "[time1 < time2] -> %s", time1 < time2 ? "true" : "false");
- Progress(time1 <= time2,
- "[time1 <= time2] -> %s", time1 <= time2 ? "true" : "false");
-
- Progress(!(time2 < time1),
- "[time2 < time2] -> %s", time2 < time1 ? "true" : "false");
- Progress(!(time2 <= time1),
- "[time2 <= time1] -> %s", time2 <= time1 ? "true" : "false");
- Progress(!(time1 > time2),
- "[time1 > time2] -> %s", time1 > time2 ? "true" : "false");
- Progress(!(time1 >= time2),
- "[time1 >= time2] -> %s", time1 >= time2 ? "true" : "false");
- Progress(!(time1 == time2),
- "[time1 == time2] -> %s", time1 == time2 ? "true" : "false");
-
- time1 = time2;
- Progress(long(time1.MicroSecs()) == 9123000*3,
- "[time1 = time2] -> time1.MicroSecs(%ld)",
- long(time1.MicroSecs()));
- Progress(time2 >= time1,
- "[time2 >= time2] -> %s", time2 >= time1 ? "true" : "false");
- Progress(time1 <= time2,
- "[time1 <= time2] -> %s", time1 <= time2 ? "true" : "false");
- Progress((time1 == time2),
- "[time1 == time2] -> %s", time1 == time2 ? "true" : "false");
-
- time1.SetZero();
- Progress(long(time1.MilliSecs()) == 0,
- "SetZero() -> MilliSecs(%ld)",
- long(time1.MilliSecs()));
-
- Progress(long(time1.MicroSecs()) == 0,
- "SetZero() -> MicroSecs(%ld)",
- long(time1.MicroSecs()));
-
- time1 = 2.5;
- Progress(long(time1.MilliSecs()) == 2500,
- "time2 = 2.5 -> MilliSecs(%ld)",
- long(time1.MilliSecs()));
-
- time2 = 3.9;
- Progress(long(time2.MicroSecs()) == 3900000,
- "time2 = 3.9 -> MicroSecs(%ld)",
- long(time2.MicroSecs()));
-
- time1.SetNow();
- FastOS_Thread::Sleep(1000);
- double waited = time1.MicroSecsToNow();
- Progress((waited >= 950000) && (waited <= 1200000),
- "Slept 1000 ms, MicroSecsToNow(%ld)", long(waited));
-
- time2.SetNow();
- FastOS_Thread::Sleep(2000);
- waited = time2.MilliSecsToNow();
- Progress((waited >= (2*950)) && (waited <= (2*1200)),
- "Slept 2000 ms, MilliSecsToNow(%ld)", long(waited));
-
- time2.SetMicroSecs(40000);
- time2.AddMicroSecs(1000000);
- Progress(long(time2.MicroSecs()) == (40000 + 1000000),
- "[SetMicroSecs(40000); AddMicroSecs(1000000)] -> MicroSecs(%ld)",
- long(time2.MicroSecs()));
-
- time1.SetMicroSecs(9123000);
- time1.SubtractMicroSecs(512000);
- Progress(long(time1.MicroSecs()) == (9123000 - 512000),
- "[SetMicroSecs(9123000); SubMicroSecs(512000)] -> MicroSecs(%ld)",
- long(time1.MicroSecs()));
-
- time1.SetMilliSecs(400);
- time1.AddMilliSecs(1000001);
- Progress(long(time1.MilliSecs()) == (400 + 1000001),
- "[SetMilliSecs(400); AddMilliSecs(1000001)] -> MilliSecs(%ld)",
- long(time1.MilliSecs()));
-
- time2.SetMilliSecs(9123213);
- time2.SubtractMilliSecs(512343);
- Progress(long(time2.MilliSecs()) == (9123213 - 512343),
- "[SetMilliSecs(9123213); SubMilliSecs(512343)] -> MilliSecs(%ld)",
- long(time2.MilliSecs()));
-
- Progress(time2.GetSeconds() == ((9123213 - 512343) / (1000)),
- "[time2.GetSeconds()] -> %ld", time2.GetSeconds());
- Progress(int64_t(time2.GetMicroSeconds()) == ((int64_t(9123213 - 512343)*1000) % (1000000)),
- "[time2.GetMicroSeconds()] -> %ld", time2.GetMicroSeconds());
-
- PrintSeparator();
- }
-
- void TimeStepTest ()
- {
- TestHeader("Time Step Test");
- FastOS_Time before, timing;
- before.SetNow();
-
- int delay = 400;
- for(int i=delay; i<3000; i+=delay)
- {
- FastOS_Thread::Sleep(delay);
-
- timing.SetNow();
- timing -= before;
-
- double millis = timing.MilliSecs();
- double correct = i;
-
- Progress((std::fabs(millis - correct)/correct) < 0.15,
- "Elapsed time measurement: %d",
- static_cast<int>(millis));
- }
-
- PrintSeparator();
- }
-
- void requireThatTimeStampCanBeConvertedToString() {
- TestHeader("requireThatTimeStampCanBeConvertedToString");
-
- int64_t time = 1424867106 * fastos::TimeStamp::SEC + 123 * fastos::TimeStamp::MS;
- fastos::TimeStamp timeStamp(time);
- std::string actualString = timeStamp.toString();
- std::string expectString = "2015-02-25 12:25:06.123 UTC";
- Progress(expectString == actualString,
- "Actual string: '%s'", actualString.c_str());
-
- PrintSeparator();
- }
-
- void requireThatTimeStampIsConstructedCorrect() {
- using fastos::TimeStamp;
- Progress(TimeStamp(97).ns() == 97l, "TimeStamp(int)");
- Progress(TimeStamp(97u).ns() == 97l, "TimeStamp(unsigned int)");
- Progress(TimeStamp(INT64_C(97)).ns() == 97l, "TimeStamp(int64_t)");
- Progress(TimeStamp(UINT64_C(97)).ns() == 97l, "TimeStamp(uint64_t)");
- Progress(TimeStamp(TimeStamp::Seconds(97.3)).ns() == 97300000000l, "TimeStamp(double)");
- PrintSeparator();
- }
-
-
- int Main () override;
-};
-
-int TimeTest::Main ()
-{
- printf("grep for the string '%s' to detect failures.\n\n", failString);
-
- Wait3SecondsTest();
- TimeArithmeticTest();
- TimeStepTest();
- requireThatTimeStampCanBeConvertedToString();
- requireThatTimeStampIsConstructedCorrect();
-
- printf("END OF TEST (%s)\n", _argv[0]);
-
- return allWasOk() ? 0 : 1;
-}
-
-
-int main (int argc, char **argv)
-{
- TimeTest app;
-
- setvbuf(stdout, nullptr, _IOLBF, 8192);
- return app.Entry(argc, argv);
-}
-
diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp
index 1e0fc53ec1e..f9293e0bc7f 100644
--- a/fastos/src/tests/typetest.cpp
+++ b/fastos/src/tests/typetest.cpp
@@ -2,9 +2,6 @@
#include "tests.h"
#include <vespa/fastos/file.h>
-#include <vespa/fastos/time.h>
-
-#include <cstdlib>
class TypeTest : public BaseTest
{
@@ -21,7 +18,6 @@ private:
Progress(true, "FastOS_StatInfo %d", sizeof(FastOS_StatInfo));
Progress(true, "FastOS_Thread: %d", sizeof(FastOS_Thread));
Progress(true, "FastOS_ThreadPool: %d", sizeof(FastOS_ThreadPool));
- Progress(true, "FastOS_Time %d", sizeof(FastOS_Time));
PrintSeparator();
}
diff --git a/fastos/src/tests/usecputest.cpp b/fastos/src/tests/usecputest.cpp
deleted file mode 100644
index 9812ed7575d..00000000000
--- a/fastos/src/tests/usecputest.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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/time.h>
-
-class ThreadRunJob;
-void UseSomeCpu(int i, ThreadRunJob *threadRunJob);
-
-class ThreadRunJob : public FastOS_Runnable
-{
-public:
- int64_t UseSomeCpu2(int64_t someNumber)
- {
- return someNumber + (someNumber/2 + someNumber*4) +
- someNumber * someNumber * someNumber;
- }
-
- void Run (FastOS_ThreadInterface *thisThread, void *arg) override
- {
- (void)thisThread;
- (void)arg;
-
- FastOS_Time before, current;
- before.SetNow();
-
- for(int i=0; i<200000; i++)
- {
- if((i % 200) == 0)
- {
- current.SetNow();
- current -= before;
- if(current.MilliSecs() > 3000)
- break;
- }
- UseSomeCpu(i, this);
- }
- delete (this);
- }
-};
-
-class UseCpuTest : public BaseTest
-{
-public:
- int Main () override
- {
- FastOS_ThreadPool pool(128*1024);
- pool.NewThread(new ThreadRunJob());
- pool.NewThread(new ThreadRunJob());
- pool.NewThread(new ThreadRunJob());
- pool.NewThread(new ThreadRunJob());
- pool.Close();
- return 0;
- }
-};
-
-void UseSomeCpu (int i, ThreadRunJob *threadRunJob)
-{
- int64_t lastVal = i;
- for(int e=0; e<100; e++)
- lastVal = threadRunJob->UseSomeCpu2(lastVal);
-}
-
-int main (int argc, char **argv)
-{
- UseCpuTest app;
- setvbuf(stdout, nullptr, _IOLBF, 8192);
- return app.Entry(argc, argv);
-}
-
diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp
index f1c726a4f51..5762d33e08b 100644
--- a/fastos/src/vespa/fastos/unix_process.cpp
+++ b/fastos/src/vespa/fastos/unix_process.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "process.h"
#include "unix_ipc.h"
-#include "time.h"
+#include "timestamp.h"
#include "ringbuffer.h"
#include <vector>
#include <cstring>
@@ -1909,8 +1909,7 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
bool timeOutKillAttempted = false;
- FastOS_Time startTime;
- startTime.SetNow();
+ fastos::StopWatch timer;
if (pollStillRunning != nullptr)
*pollStillRunning = true;
@@ -1937,19 +1936,13 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
break;
if ((timeOutSeconds != -1) && !timeOutKillAttempted) {
- FastOS_Time waitTime;
- waitTime.SetNow();
- waitTime -= startTime;
-
- if (waitTime.MilliSecs() >= (timeOutSeconds * 1000)) {
+ if (timer.elapsed().ms() >= (timeOutSeconds * 1000)) {
process->Kill();
timeOutKillAttempted = true;
}
}
-
- // Sleep 100 ms
FastOS_Thread::Sleep(100);
}