Simplify Clocks.
GitOrigin-RevId: 6684cd9d98efea14d00317d1975b58aa7e2c8a11
This commit is contained in:
parent
301ff466e1
commit
b35862bd71
@ -10,12 +10,13 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
ClocksDefault::Duration ClocksDefault::monotonic() {
|
double Clocks::monotonic() {
|
||||||
|
// TODO write system specific functions, because std::chrono::steady_clock is steady only under Windows
|
||||||
auto duration = std::chrono::steady_clock::now().time_since_epoch();
|
auto duration = std::chrono::steady_clock::now().time_since_epoch();
|
||||||
return static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count()) * 1e-9;
|
return static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count()) * 1e-9;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClocksDefault::Duration ClocksDefault::system() {
|
double Clocks::system() {
|
||||||
auto duration = std::chrono::system_clock::now().time_since_epoch();
|
auto duration = std::chrono::system_clock::now().time_since_epoch();
|
||||||
return static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count()) * 1e-9;
|
return static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count()) * 1e-9;
|
||||||
}
|
}
|
||||||
|
@ -8,21 +8,10 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
class ClocksBase {
|
struct Clocks {
|
||||||
public:
|
static double monotonic();
|
||||||
using Duration = double;
|
|
||||||
|
static double system();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: (maybe) write system specific functions.
|
|
||||||
class ClocksDefault {
|
|
||||||
public:
|
|
||||||
using Duration = ClocksBase::Duration;
|
|
||||||
|
|
||||||
static Duration monotonic();
|
|
||||||
|
|
||||||
static Duration system();
|
|
||||||
};
|
|
||||||
|
|
||||||
using Clocks = ClocksDefault;
|
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
Reference in New Issue
Block a user