Hello:
This post is slightly off-topic, but I wanted to agree that some timers have a resolution of 1/64 of second, that is, 0.015625 seconds.
I wrote a short Fortran 95 programme to show it:
Code: Select all
program tiempo
implicit none
integer::i
integer,parameter::n=100000 ! 1e+5
real::t_CLOCK(n)
real(2)::a(n),t_CPU_TIME(n),t_DCLOCK(n)
do i=1,n
a(i)=i*1d0
call cpu_time(t_CPU_TIME(i))
end do
do i=1,n
a(i)=i*1d0
call clock@(t_CLOCK(i))
end do
do i=1,n
a(i)=i*1d0
call dclock@(t_DCLOCK(i))
end do
open(unit=11,file='Output_CPU_TIME.txt',status='unknown',action='write')
do i=1,n
write(11,*) t_CPU_TIME(i)
end do
close(11)
open(unit=101,file='Output_CLOCK.txt',status='unknown',action='write')
do i=1,n
write(101,*) t_CLOCK(i)
end do
close(101)
open(unit=110,file='Output_DCLOCK.txt',status='unknown',action='write')
do i=1,n
write(110,*) t_DCLOCK(i)
end do
close(110)
end program
I used three routines of Silverfrost Plato IDE compiler for Fortran 95: CPU_TIME(), CLOCK@() and DCLOCK@(). I recorded all the times given by those three different timers and printed them in three separated Notepads. The result is that each Notepad has lots of the same numbers and then sudden gaps of 1/64 of second. I copy here the only different times (in seconds, of course):
Code: Select all
CPU_TIME()
0.359375000000
0.375000000000
0.390625000000
0.406250000000
0.421875000000
0.437500000000
Code: Select all
CLOCK@()
5.10900
5.12500
5.14100
5.15600
Code: Select all
DCLOCK@()
5.15599999999
5.17199999999
5.18799999999
CPU_TIME() is the best for show the granularity of 0.015625 seconds. Furthermore: 0.359375/0.015625 = 23 (an exact integer), so the times printed in Output_CPU_TIME.txt are 23/64, 24/64, 25/64, 26/64, 27/64 and 28/64 of second.
I did 100000 calls in each do loop, but the total elapsed time is very different for each timer. I ran the programme only once. My PC has Windows XP (32-bit).
I hope that this info will be somewhat useful.
Regards from Spain.
Ajedrecista.