Hi, all
Frank suggested using the CPU timer, and I agree that it's a much better benchmark than the clock timer (I keep discovering gems in gpc.pas!). But I'm getting identical results from the two timers:
var time1, time2 : longCard; dummy, cpu1, cpu2 : integer; ... time1 := GetMicroSecondTime; dummy := 0; cpu1 := GetCPUTime(dummy);
for i := 1 to big do j := randNorm(0.0, 1.0);
dummy := 0; cpu2 := GetCPUTime(dummy); time2 := GetMicroSecondTime; writeln('Time for ', big:1, ' randNorms: ', ((time2-time1)*0.000001):7:2, ' seconds, ', (cpu2-cpu1):5, ' cpu seconds.'); ...
A note in gpc.pas says that the argument to GetCPUTime can be null and is then ignored.
When the computer is idle except for this program, I get: Time for 100000000 randNorms: 171.03 seconds, 171 cpu seconds.
When I'm checking email, opening files, etc., I get: Time for 100000000 randNorms: 202.29 seconds, 202 cpu seconds.
What am I doing wrong here - or is GetCPUTime not working?
Toby