On Mon, 1 Mar 2004, Toby Ewing wrote:
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.'); ..
When the computer is idle except for this program, I get: Time for 100000000 randNorms: 171.03 seconds, 171 cpu seconds.
The for-loop is cpu-intensive. You might try repeating the tests with: time <name-of your-program>
then change the for-loop: for i = 1 to not-so-big do begin j := randNorm(0.0, 1.0); writeln( i, ' ',j ); end;
You should get some interesting numbers.
Russ
p.s. couldn't find "randNorm" so used "random( 1000 )"
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