timing loops -> how to calibrate

Paul Barton-Davis (pbd@Op.Net)
Tue, 14 Jul 1998 10:38:00 -0400


Whats the easiest way of converting something like:

for (i = 0; i < 50000; i++);

into:

for (i = 0; i < 4; i++) {
tenmicrosecs();
}

Should I just write a test loop something like:

now = jiffies;
for (i = 0; i < 1000000; i++);
usecs_per_thousand_iterations = (jiffies - now/1000)/10000;

Does such a calibration already exist in the kernel, and if so, how do
I use it ? I want to alter some driver code from using
CPU-speed-dependent timing loops to ones based on fixed real times.

--p

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html