Mail Archives: djgpp/2001/07/13/14:30:11
Eli Zaretskii wrote:
> The problem is that `uclock' returns a value of the type uclock_t, which is
> defined as long long. That's a 64-bit quantity, and since `uclock's
> resolution is 840 nanoseconds, the 64-bit type overflows in about 48 hours.
I haven't tried using uclock() to time long intervals, but overflow of the
64-bit quantity is not the problem, since 840ns * 2^64 = 1.5E+13 seconds =
50000 years.
Back when people were first having problems with uclock(), I switched over to
using an rdtsc-based timer. It is not as portable as uclock(), so I haven't
proposed it to the DJGPP developers as a replacement, but it has performed
well for me.
rdtsc measures in processor clocks instead of seconds, but one can get around
that problem by timing the rdtsc timer against rawclock() for a couple of
ticks on the first call to the timer, which enables one to estimate the CPU
clock rate.
If there is interest in this style of timing, I would consider submitting the
code.
-Eric
- Raw text -