sled/src/system_time.cc

16 lines
337 B
C++
Raw Normal View History

2024-02-23 18:07:37 +08:00
#include "sled/system_time.h"
#include "sled/time_utils.h"
namespace sled {
int64_t
SystemTimeNanos()
{
int64_t ticks;
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
2024-02-28 00:23:29 +08:00
ticks = kNumNanosecsPerSec * static_cast<int64_t>(ts.tv_sec)
+ static_cast<int64_t>(ts.tv_nsec);
2024-02-23 18:07:37 +08:00
return ticks;
}
}// namespace sled