Is there a similar function like GetTickCount() for Linux?
I´ve tried out some other sutff, but they didn´t work at all.
So it should return the exact time in milliseconds since startup.
/// Returns the number of ticks since an undefined time (usually system startup).
static uint64_t GetTickCountMs()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t)(ts.tv_nsec / 1000000) + ((uint64_t)ts.tv_sec * 1000ull);
}
Also useful...
/// Computes the elapsed time, in milliseconds, between two 'timespec'.
inline uint32_t TimeElapsedMs(const struct timespec& tStartTime, const struct timespec& tEndTime)
{
return 1000*(tEndTime.tv_sec - tStartTime.tv_sec) +
(tEndTime.tv_nsec - tStartTime.tv_nsec)/1000000;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With