some fixes [multithreading,..]
needed interface changes [new options] logger for android wifi-ap-optimization new test-cases
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef TIMESTAMP_H
|
||||
#define TIMESTAMP_H
|
||||
|
||||
#include <chrono>
|
||||
|
||||
/**
|
||||
* helper-class to handle timestamps
|
||||
*/
|
||||
@@ -25,16 +27,32 @@ public:
|
||||
/** get timestamp from the given value which represents seconds */
|
||||
static inline Timestamp fromSec(const float sec) {return Timestamp(sec*1000);}
|
||||
|
||||
/** get timestamp for the current unix-time */
|
||||
static inline Timestamp fromUnixTime() {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto duration = now.time_since_epoch();
|
||||
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
|
||||
return Timestamp(millis);
|
||||
}
|
||||
|
||||
/** get timestamp for the current system-time */
|
||||
static inline Timestamp fromRunningTime() {
|
||||
static Timestamp startup = fromUnixTime();
|
||||
return fromUnixTime() - startup;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** get timestamp in milliseconds */
|
||||
inline uint64_t ms() const {return _ms;}
|
||||
inline int64_t ms() const {return _ms;}
|
||||
|
||||
/** get timestamp in seconds */
|
||||
inline float sec() const {return _ms/1000.0f;}
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** is this timestamp zero? */
|
||||
@@ -48,17 +66,23 @@ public:
|
||||
|
||||
/** smaller than the given one? */
|
||||
bool operator < (const Timestamp& o) const {return _ms < o._ms;}
|
||||
bool operator <= (const Timestamp& o) const {return _ms <= o._ms;}
|
||||
|
||||
/** greater than the given one? */
|
||||
bool operator > (const Timestamp& o) const {return _ms > o._ms;}
|
||||
bool operator >= (const Timestamp& o) const {return _ms >= o._ms;}
|
||||
|
||||
|
||||
|
||||
Timestamp operator - (const Timestamp& o) const {return Timestamp(_ms - o._ms);}
|
||||
|
||||
Timestamp operator + (const Timestamp& o) const {return Timestamp(_ms + o._ms);}
|
||||
|
||||
/** cast to float */
|
||||
operator float () const {return sec();}
|
||||
Timestamp operator * (const float val) const {return Timestamp(_ms * val);}
|
||||
|
||||
|
||||
// /** cast to float */
|
||||
// operator float () const {return sec();}
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user