How to use rdtsc to get time
Closed this issue · 1 comments
qdztxc commented
It's described in the README.md that rdtsc is the fastest way to get time under linux.
Benchmark | Std. Dev. | Median |
---|---|---|
One integer (no clock) | 0 ns | 8 ns |
One integer (TSC clock) | 0 ns | 9 ns |
One integer (sys clock) | 0 ns | 34 ns |
One integer (poison cache) | 8 ns | 740 ns |
One string | 0 ns | 38 ns |
Three floats | 0 ns | 30 ns |
But in the soruce code I saw clockNow uses clock_gettime. Is there a way or special version that uses rdtsc to get time under linux?
Thanks.
erenon commented
Hi,
Here's an example how to do it: https://github.com/Morgan-Stanley/binlog/blob/master/example/TscClock.cpp