aboutsummaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-06 20:17:56 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-09 20:43:38 +0000
commit9156592055b871be41b1f634ee37842854dc73a4 (patch)
tree9fe512730a78b950ed07ee7f84a330821a109062 /fastos
parent3a8c63f34d8554573b42b0c3749e44ad4f43fb0e (diff)
Use std::chrono.
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp24
-rw-r--r--fastos/src/vespa/fastos/timestamp.h19
2 files changed, 1 insertions, 42 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index 14825d7d4f4..ef206067900 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -14,10 +14,7 @@ namespace fastos {
const TimeStamp::TimeT TimeStamp::MILLI;
const TimeStamp::TimeT TimeStamp::MICRO;
const TimeStamp::TimeT TimeStamp::NANO;
-const TimeStamp::TimeT TimeStamp::US;
-const TimeStamp::TimeT TimeStamp::MS;
const TimeStamp::TimeT TimeStamp::SEC;
-const TimeStamp::TimeT TimeStamp::MINUTE;
using seconds = std::chrono::duration<double>;
@@ -56,27 +53,6 @@ steady_now() {
}
-std::ostream &
-operator << (std::ostream & os, SteadyTimeStamp ts) {
- return os << ts.toString();
-}
-
-SteadyTimeStamp
-ClockSteady::now()
-{
- return steady_now();
-}
-
-const SteadyTimeStamp SteadyTimeStamp::ZERO;
-const SteadyTimeStamp SteadyTimeStamp::FUTURE(TimeStamp::FUTURE);
-
-system_clock::time_point
-SteadyTimeStamp::toUTC() const {
- system_clock::time_point nowUtc = system_clock::now();
- SteadyTimeStamp nowSteady = ClockSteady::now();
- return system_clock::time_point (std::chrono::nanoseconds(nowUtc.time_since_epoch().count() - (nowSteady - *this).ns()));
-}
-
StopWatch::StopWatch()
: _startTime(steady_now())
{ }
diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h
index 5dd6c350602..0d23cf7151f 100644
--- a/fastos/src/vespa/fastos/timestamp.h
+++ b/fastos/src/vespa/fastos/timestamp.h
@@ -15,10 +15,7 @@ public:
static const TimeT MILLI = 1000LL;
static const TimeT MICRO = 1000*MILLI;
static const TimeT NANO = 1000*MICRO;
- static const TimeT US = MILLI;
- static const TimeT MS = MICRO;
static const TimeT SEC = NANO;
- static const TimeT MINUTE = 60*SEC;
class Seconds {
public:
explicit Seconds(double v) : _v(v * NANO) {}
@@ -26,10 +23,8 @@ public:
private:
TimeT _v;
};
- enum Special { FUTURE };
TimeStamp() : _time(0) { }
TimeStamp(const timeval & tv) : _time(tv.tv_sec*SEC + tv.tv_usec*MILLI) { }
- TimeStamp(Special s) : _time(std::numeric_limits<TimeT>::max()) { (void) s; }
TimeStamp(int v) : _time(v) { }
TimeStamp(unsigned int v) : _time(v) { }
TimeStamp(long v) : _time(v) { }
@@ -48,8 +43,7 @@ public:
double sec() const { return val()/1000000000.0; }
std::string toString() const { return asString(sec()); }
static std::string asString(double timeInSeconds);
- static std::string asString(std::chrono::system_clock::time_point duration);
- static TimeStamp fromSec(double sec) { return Seconds(sec); }
+ static std::string asString(std::chrono::system_clock::time_point time);
private:
TimeT _time;
};
@@ -61,8 +55,6 @@ inline TimeStamp operator *(double a, TimeStamp b) { return TimeStamp(static_cas
class SteadyTimeStamp {
public:
- static const SteadyTimeStamp ZERO;
- static const SteadyTimeStamp FUTURE;
SteadyTimeStamp() : _timeStamp() { }
explicit SteadyTimeStamp(TimeStamp timeStamp) : _timeStamp(timeStamp) { }
@@ -87,20 +79,11 @@ public:
friend bool operator > (SteadyTimeStamp a, SteadyTimeStamp b) {
return a._timeStamp > b._timeStamp;
}
- std::chrono::system_clock::time_point toUTC() const;
std::string toString() const { return _timeStamp.toString(); };
private:
TimeStamp _timeStamp;
};
-std::ostream & operator << (std::ostream & os, SteadyTimeStamp ts);
-
-class ClockSteady
-{
-public:
- static SteadyTimeStamp now();
-};
-
class StopWatch
{
public: