summaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-15 18:22:49 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-15 18:22:49 +0000
commit00894143c792c8e63ec3c161f8733fef86c501e1 (patch)
tree4a9dd166098dc990affd07a403afdc1b9b499cd9 /staging_vespalib
parentec90577f70dab04c7d20132559ce77adfc80a1c8 (diff)
Add typesafe SteadyTimeStamp.
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/tests/array/allocinarray_benchmark.cpp2
-rw-r--r--staging_vespalib/src/tests/array/sort_benchmark.cpp2
-rw-r--r--staging_vespalib/src/tests/clock/clock_test.cpp6
-rw-r--r--staging_vespalib/src/tests/rusage/rusage_test.cpp4
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.h6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/doom.cpp4
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/doom.h6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/rusage.cpp23
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/rusage.h4
9 files changed, 31 insertions, 26 deletions
diff --git a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp
index 5e208864502..a9e1499f014 100644
--- a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp
+++ b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp
@@ -111,7 +111,7 @@ Test::Main()
count = strtol(_argv[2], NULL, 0);
}
TEST_INIT("allocinarray_benchmark");
- fastos::TimeStamp start(fastos::ClockSteady::now());
+ fastos::SteadyTimeStamp start(fastos::ClockSteady::now());
if (type == "direct") {
benchmarkTree(count);
} else {
diff --git a/staging_vespalib/src/tests/array/sort_benchmark.cpp b/staging_vespalib/src/tests/array/sort_benchmark.cpp
index bdb96567f9e..03a99aa044f 100644
--- a/staging_vespalib/src/tests/array/sort_benchmark.cpp
+++ b/staging_vespalib/src/tests/array/sort_benchmark.cpp
@@ -100,7 +100,7 @@ Test::Main()
payLoad = strtol(_argv[3], NULL, 0);
}
TEST_INIT("sort_benchmark");
- fastos::TimeStamp start(fastos::ClockSteady::now());
+ fastos::SteadyTimeStamp start(fastos::ClockSteady::now());
if (payLoad < 8) {
typedef TT<8> T;
if (type == "sortdirect") {
diff --git a/staging_vespalib/src/tests/clock/clock_test.cpp b/staging_vespalib/src/tests/clock/clock_test.cpp
index b733869c39b..45f17bbba92 100644
--- a/staging_vespalib/src/tests/clock/clock_test.cpp
+++ b/staging_vespalib/src/tests/clock/clock_test.cpp
@@ -21,13 +21,13 @@ Test::Main()
Clock clock(0.050);
FastOS_ThreadPool pool(0x10000);
ASSERT_TRUE(pool.NewThread(&clock, NULL) != NULL);
- uint64_t start = clock.getTimeNS();
+ fastos::SteadyTimeStamp start = clock.getTimeNS();
FastOS_Thread::Sleep(5000);
- uint64_t stop = clock.getTimeNS();
+ fastos::SteadyTimeStamp stop = clock.getTimeNS();
EXPECT_TRUE(stop > start);
FastOS_Thread::Sleep(6000);
clock.stop();
- uint64_t stop2 = clock.getTimeNS();
+ fastos::SteadyTimeStamp stop2 = clock.getTimeNS();
EXPECT_TRUE(stop2 > stop);
EXPECT_TRUE((stop2 - stop)/TimeStamp::MICRO > 1000);
TEST_DONE();
diff --git a/staging_vespalib/src/tests/rusage/rusage_test.cpp b/staging_vespalib/src/tests/rusage/rusage_test.cpp
index 503018ee70d..23b9d4072b1 100644
--- a/staging_vespalib/src/tests/rusage/rusage_test.cpp
+++ b/staging_vespalib/src/tests/rusage/rusage_test.cpp
@@ -30,12 +30,12 @@ Test::testRUsage()
RUsage diff = r2-r1;
EXPECT_EQUAL(diff.toString(), r2.toString());
{
- RUsage then = RUsage::createSelf(7);
+ RUsage then = RUsage::createSelf(fastos::SteadyTimeStamp(7));
RUsage now = RUsage::createSelf();
EXPECT_NOT_EQUAL(now.toString(), then.toString());
}
{
- RUsage then = RUsage::createChildren(1337583);
+ RUsage then = RUsage::createChildren(fastos::SteadyTimeStamp(1337583));
RUsage now = RUsage::createChildren();
EXPECT_NOT_EQUAL(now.toString(), then.toString());
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.h b/staging_vespalib/src/vespa/vespalib/util/clock.h
index b44b1454cd4..43cea258d23 100644
--- a/staging_vespalib/src/vespa/vespalib/util/clock.h
+++ b/staging_vespalib/src/vespa/vespalib/util/clock.h
@@ -20,7 +20,7 @@ private:
Clock(const Clock &);
Clock & operator = (const Clock &);
- mutable fastos::TimeStamp _timeNS;
+ mutable fastos::SteadyTimeStamp _timeNS;
int _timePeriodMS;
std::mutex _lock;
std::condition_variable _cond;
@@ -35,13 +35,13 @@ public:
Clock(double timePeriod=0.100);
~Clock();
- fastos::TimeStamp getTimeNS() const {
+ fastos::SteadyTimeStamp getTimeNS() const {
if (!_running) {
setTime();
}
return _timeNS;
}
- fastos::TimeStamp getTimeNSAssumeRunning() const { return _timeNS; }
+ fastos::SteadyTimeStamp getTimeNSAssumeRunning() const { return _timeNS; }
void stop();
};
diff --git a/staging_vespalib/src/vespa/vespalib/util/doom.cpp b/staging_vespalib/src/vespa/vespalib/util/doom.cpp
index aa737cc7464..df20981c584 100644
--- a/staging_vespalib/src/vespa/vespalib/util/doom.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/doom.cpp
@@ -4,10 +4,10 @@
namespace vespalib {
-Doom::Doom(const vespalib::Clock &clock, fastos::TimeStamp timeOfDoom) :
+Doom::Doom(const vespalib::Clock &clock, fastos::SteadyTimeStamp timeOfDoom) :
_clock(clock),
_timeOfDoom(timeOfDoom)
{
}
-} // namespace vespalib
+} // namespace vespalib \ No newline at end of file
diff --git a/staging_vespalib/src/vespa/vespalib/util/doom.h b/staging_vespalib/src/vespa/vespalib/util/doom.h
index 623cc23fcc8..ee0c1af3177 100644
--- a/staging_vespalib/src/vespa/vespalib/util/doom.h
+++ b/staging_vespalib/src/vespa/vespalib/util/doom.h
@@ -9,11 +9,11 @@ namespace vespalib {
class Doom
{
private:
- const vespalib::Clock &_clock;
- fastos::TimeStamp _timeOfDoom;
+ const vespalib::Clock &_clock;
+ fastos::SteadyTimeStamp _timeOfDoom;
public:
- Doom(const vespalib::Clock &clock, fastos::TimeStamp timeOfDoom);
+ Doom(const vespalib::Clock &clock, fastos::SteadyTimeStamp timeOfDoom);
bool doom() const {
return (_clock.getTimeNSAssumeRunning() > _timeOfDoom);
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/rusage.cpp b/staging_vespalib/src/vespa/vespalib/util/rusage.cpp
index 96a9c7ef206..32f76775586 100644
--- a/staging_vespalib/src/vespa/vespalib/util/rusage.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/rusage.cpp
@@ -30,37 +30,42 @@ RUsage::RUsage() :
ru_nivcsw = 0;
}
-RUsage RUsage::createSelf()
+RUsage
+RUsage::createSelf()
{
- return createSelf(0);
+ return createSelf(fastos::SteadyTimeStamp());
}
-RUsage RUsage::createChildren()
+RUsage
+RUsage::createChildren()
{
- return createChildren(0);
+ return createChildren(fastos::SteadyTimeStamp());
}
-RUsage RUsage::createSelf(const fastos::TimeStamp & since)
+RUsage
+RUsage::createSelf(fastos::SteadyTimeStamp since)
{
RUsage r;
- r._time = fastos::TimeStamp(fastos::ClockSteady::now()) - since;
+ r._time = fastos::ClockSteady::now() - since;
if (getrusage(RUSAGE_SELF, &r) != 0) {
throw std::runtime_error(vespalib::make_string("getrusage failed with errno = %d", errno).c_str());
}
return r;
}
-RUsage RUsage::createChildren(const fastos::TimeStamp & since)
+RUsage
+RUsage::createChildren(fastos::SteadyTimeStamp since)
{
RUsage r;
- r._time = fastos::TimeStamp(fastos::ClockSteady::now()) - since;
+ r._time = fastos::ClockSteady::now() - since;
if (getrusage(RUSAGE_CHILDREN, &r) != 0) {
throw std::runtime_error(vespalib::make_string("getrusage failed with errno = %d", errno).c_str());
}
return r;
}
-vespalib::string RUsage::toString()
+vespalib::string
+RUsage::toString()
{
vespalib::string s;
if (_time.sec() != 0.0) s += make_string("duration = %1.6f\n", _time.sec());
diff --git a/staging_vespalib/src/vespa/vespalib/util/rusage.h b/staging_vespalib/src/vespa/vespalib/util/rusage.h
index 07b0c5814bc..381d4d764e7 100644
--- a/staging_vespalib/src/vespa/vespalib/util/rusage.h
+++ b/staging_vespalib/src/vespa/vespalib/util/rusage.h
@@ -17,12 +17,12 @@ public:
* Will create an RUsage and initialize member with RUSAGE_SELF
**/
static RUsage createSelf();
- static RUsage createSelf(const fastos::TimeStamp & since);
+ static RUsage createSelf(fastos::SteadyTimeStamp since);
/**
* Will create an RUsage and initialize member with RUSAGE_CHILDREN
**/
static RUsage createChildren();
- static RUsage createChildren(const fastos::TimeStamp & since);
+ static RUsage createChildren(fastos::SteadyTimeStamp since);
/**
* Will create an RUsage and initialize member with RUSAGE_CHILDREN
**/