Noone makes me give up
So, this is the new version, rounding the same way, as PureBasic does:
My Test brought an optimization from 25Seconds to 11 Seconds:
Code: Select all
#Compare=0
Global a,b,c.l,*adr1.long,*adr2.long,adr1.l,adr2.l
adr1=AllocateMemory(80000)
adr2=AllocateMemory(80000)
;Rechnung: c=a/8
Zeit=GetTickCount_()
For b=1 To 99999
CompilerIf #compare
*adr1=adr1
CompilerEndIf
For a=-9999 To 9999
! MOV eax,dword [v_a]
; ! MOV ebx,dword [v_a]
;! MOV eax,ebx
! MOV ebx,8
! CDQ
! IDIV ebx
;! MOV ebx, eax
;! MOV dword [v_c],ebx
! MOV dword [v_c],eax
CompilerIf #Compare
*adr1\l=c
*adr1+4
CompilerEndIf
Next
Next
zeit2=GetTickCount_()
For b=1 To 99999
CompilerIf #compare
*adr2=adr2
CompilerEndIf
; CallDebugger
For a=-9999 To 9999
! MOV ebx,dword [v_a]
! SAR ebx,3
! MOV dword [v_c],ebx
! CMP ebx,0
! JNL l___div_end
! SAL ebx,3
! CMP dword[v_a],ebx
! JE l___div_end
! INC dword[v_c]
__div_end:
CompilerIf #compare
*adr2\l=c
*adr2+4
CompilerEndIf
Next
Next
zeit3=GetTickCount_()
CompilerIf #compare
*adr1=adr1
*adr2=adr2
dif=0
For a=0 To 19998
If *adr1\l<>*adr2\l
INC dif
Debug Str(a-9999)+"/8="+Str(*adr1\l)+" SAR a,3="+Str(*adr2\l)+" %8="+Str(a%8)
EndIf
*adr1+4
*adr2+4
Next
CompilerEndIf
MessageRequester("Ergebnis:","Freds Method: "+Str(zeit2-zeit)+"ms"+Chr(13)+"My Method: "+Str(zeit3-zeit2)+"ms"+Chr(13)+"Menge der Unterschiede: "+Str(dif))