Use RDTSC instruction to measure time on x86 architecture
In x86 architecture, RDTSC instruction reads current time stamp counter from the hardware. This is a better cost measurement for a program than using GNU time. It’s overhead is low and accuracy is high. You can simply add the following function to get the current counter.
typedef unsigned long long cycles_t;
inline cycles_t currentcycles() {
cycles_t result;
__asm__ __volatile__ ("rdtsc" : "=A" (result));
return result;
}

January 8th, 2010 at 8:28 pm
Sometimes exact UTC time is required. Ntp server steps in with powerful linux tools (like GPS NTP on linux)
January 13th, 2010 at 8:29 pm
RDTSC is using the hardware clock. It indicates # of cycles, and not the time. Cycles are better indication of the time spent in an application, because of the granularity it can measure.