3 ms·
At least on a single system, it's not that hard. You have to get over the fact that you can't compute accurate intervals by recording two human-datetime timest
by dap 13y ago
At least on a single system, it's not that hard. You have to get over the fact that you can't compute accurate intervals by recording two human-datetime timestamps. Even aside from the myriad edge cases around date arithmetic, an administrator (or NTP) can always reset the clock between the endpoints of your interval, and your computation may be very wrong.
If you want a human timestamp, use gettimeofday[0] and related functions. If you want something to compute actual elapsed seconds with, use high-resolution timestamps([2] and [3]). You just can't have both, and that's because of the way human dates work, not the way we represent them.
[0] http://pubs.opengroup.org/onlinepubs/009695399/functions/gettimeofday.html http://pubs.opengroup.org/onlinepubs/009695399/functions/get...
[1] http://www.lehman.cuny.edu/cgi-bin/man-cgi?gethrtime+3 http://www.lehman.cuny.edu/cgi-bin/man-cgi?gethrtime+3
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html http://pubs.opengroup.org/onlinepubs/9699919799/functions/cl...