Strange behavior
Posted: Mon Apr 01, 2019 7:01 pm
I wrote this simple program to see how fast certain arithmetic instructions are. I observed two different timings depending on how many spaces are between the quote marks on the line after Openconsole!!!
Note this with the debugger off.
How can this be?
On my pc 64 bit windows I get either 2.4 or 7.0 for the looptime. Maybe some of you could see if this happens.
Note this with the debugger off.
How can this be?
On my pc 64 bit windows I get either 2.4 or 7.0 for the looptime. Maybe some of you could see if this happens.
Code: Select all
ntimes=1e7
nsecs=ntimes/1.0e6
remainder2=0
a.l=999
b.i=567
e.d=0.6789
f.d=567
atime=ElapsedMilliseconds()
For i=1 To ntimes
Next
btime=ElapsedMilliseconds()
For i=1 To ntimes
c=a*b
Next
ctime=ElapsedMilliseconds()
For i=1 To ntimes
f=Sin(e)
Next
dtime=ElapsedMilliseconds()
For i=1 To ntimes
c=a/b
Next
etime=ElapsedMilliseconds()
For i=1 To ntimes
c=a/b
remainder1=a-b*c
Next
ftime=ElapsedMilliseconds()
For i=1 To ntimes
c=a/b
EnableASM
mov remainder2, rdx
DisableASM
Next
gtime=ElapsedMilliseconds()
For i=1 To ntimes
quotient.d=e/f
Next
htime=ElapsedMilliseconds()
LoopTime=btime-atime
OpenConsole()
Print(Str(atime)+" "+Str(btime))
PrintN("Times in nsecs")
PrintN("Loop time for "+Str(ntimes)+" loops "+StrF(LoopTime/nsecs,1))
PrintN("Integer Mult "+StrF((ctime-btime-LoopTime)/nsecs,1))
PrintN("Sin (float double) "+StrF((dtime-ctime-LoopTime)/nsecs,1))
PrintN("Integer Div "+StrF((etime-dtime-LoopTime)/nsecs,1))
PrintN("Integer Div with Remainder "+StrF((ftime-etime-LoopTime)/nsecs,1))
PrintN("Integer Div with Remainder using assembler "+StrF((gtime-ftime-LoopTime)/nsecs,1))
PrintN("Double float divide "+StrF((htime-gtime-LoopTime)/nsecs,1))
Input()
End