Clocks: use CLOCK_[BOOTTIME,MONOTONIC_RAW] for Clocks::monotonic
GitOrigin-RevId: 729311e1a7a36a9245ecdb5921b81c4834ec1dc6
This commit is contained in:
parent
129e673769
commit
9c40e37288
@ -25,26 +25,14 @@ double Clocks::monotonic() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLOCK_UPTIME_RAW
|
#ifdef CLOCK_MONOTONIC_RAW
|
||||||
{
|
{
|
||||||
static bool skip = []() {
|
static bool skip = []() {
|
||||||
struct timespec spec;
|
struct timespec spec;
|
||||||
return clock_gettime(CLOCK_UPTIME_RAW, &spec) != 0;
|
return clock_gettime(CLOCK_MONOTONIC_RAW, &spec) != 0;
|
||||||
}();
|
}();
|
||||||
struct timespec spec;
|
struct timespec spec;
|
||||||
if (!skip && clock_gettime(CLOCK_UPTIME_RAW, &spec) == 0) {
|
if (!skip && clock_gettime(CLOCK_MONOTONIC_RAW, &spec) == 0) {
|
||||||
return static_cast<double>(spec.tv_nsec) * 1e-9 + static_cast<double>(spec.tv_sec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef CLOCK_UPTIME
|
|
||||||
{
|
|
||||||
static bool skip = []() {
|
|
||||||
struct timespec spec;
|
|
||||||
return clock_gettime(CLOCK_UPTIME, &spec) != 0;
|
|
||||||
}();
|
|
||||||
struct timespec spec;
|
|
||||||
if (!skip && clock_gettime(CLOCK_UPTIME, &spec) == 0) {
|
|
||||||
return static_cast<double>(spec.tv_nsec) * 1e-9 + static_cast<double>(spec.tv_sec);
|
return static_cast<double>(spec.tv_nsec) * 1e-9 + static_cast<double>(spec.tv_sec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user