41 double TimeStamp::TimespecToDouble(const ::timespec& LargeInt)
43 return double(LargeInt.tv_sec) + double(LargeInt.tv_nsec) / 1e9;
46 ::timespec TimeStamp::DoubleToTimespec(
double TimeS)
49 if (!(TimeS < 4e9 && TimeS > 0.0))
52 DeltaTime.tv_nsec = 0;
56 DeltaTime.tv_sec = ::time_t(TimeS);
57 DeltaTime.tv_nsec =
static_cast<long int>((TimeS - double(DeltaTime.tv_sec)) * 1e9);
66 Res.tv_sec =
m_TimeStamp.tv_sec - EarlierTime.m_TimeStamp.tv_sec;
67 Res.tv_nsec =
m_TimeStamp.tv_nsec - EarlierTime.m_TimeStamp.tv_nsec;
72 Res.tv_nsec += 1000000000;
75 return TimespecToDouble(Res);
80 ::timespec Dbl = DoubleToTimespec(TimeS);
92 ::timespec Dbl = DoubleToTimespec(TimeS);
136 BOOL
CounterHW = QueryPerformanceFrequency(&ClockFrequency);
155 return LargeInt.HighPart *
m_DwordSize + LargeInt.LowPart;
160 LARGE_INTEGER DeltaTime;
161 DeltaTime.LowPart = 0;
162 DeltaTime.HighPart = 0;
163 if (!(TimeS < 4e9 && TimeS > 0.0))
184 if ((Res.LowPart <
m_TimeStamp.LowPart) || (Res.LowPart < Dbl.LowPart))
194 Res.HighPart =
m_TimeStamp.HighPart - Dbl.HighPart;
static double m_SecPerCount
Seconds per counts.
void setTimeStamp(const long &lSeconds, const long &lNanoSeconds)
void operator+=(double TimeS)
Increase the timestamp by TimeS seconds.
static double LargeIntToDouble(const LARGE_INTEGER &LargeInt)
Conversion timespec -> double.
double operator-(const TimeStamp &EarlierTime) const
Retrieves time difference in seconds.
LARGE_INTEGER m_TimeStamp
Internal time stamp data.
LARGE_INTEGER ClockFrequency
bool operator>(const TimeStamp &Time)
Checks if this time is after time "Time".
bool operator<(const TimeStamp &Time)
Checks if this time is before time "Time".
static double m_DwordSize
Size of a Dword field.
void SetNow()
Makes time measurement.
void operator-=(double TimeS)
Reduces the timestamp by TimeS seconds.
void getTimeStamp(long &lSeconds, long &lNanoSeconds)
static LARGE_INTEGER DoubleToLargeInt(double TimeS)
Conversion double -> LARGE_INTEGER.