Code: Select all
SetPriorityClass_( GetCurrentProcess_(), #HIGH_PRIORITY_CLASS)
Code: Select all
SetPriorityClass_( GetCurrentProcess_(), #HIGH_PRIORITY_CLASS)
Code: Select all
!macro Blign value ;Begin Macro
!{
!a = value - (($ - $$) mod value) ;$=this Offset-Adress, $$=Basis-Adress of the Section
!if a = value
!a = 0
!end if
!if a=1
!irp value, $90 ;NOP, the well-known standard-value
!\{
!DB value
!\}
!end if
!if a=2
!irp value, $8B, $C0 ;MOV EAX,EAX
!\{
!DB value
!\}
!end if
!if a=3
!irp value, $8D, $40, $00 ;LEA EAX, dword ptr[EAX + 00]
!\{
!DB value
!\}
!end if
!if a=4
!irp value, $8D, $44, $20, $00 ;LEA EAX, dword ptr[EAX]
!\{
!DB value
!\}
!end if
!if a=5
!irp value, $66, $8D, $54, $22, $00 ;LEA DX, word ptr[EDX]
!\{
!DB value
!\}
!end if
!if a=6
!irp value, $8D, $80, $00, $00, $00, $00 ;LEA EAX, dword ptr[EAX + 00000000]
!\{
!DB value
!\}
!end if
!if a=7
!irp value, $8D, $04, $05, $00, $00, $00, $00 ;LEA EAX, dword ptr[EAX + 00000000]
!\{
!DB value
!\}
!end if
!if a=8
!irp value, $66, $8D, $04, $05, $00, $00, $00, $00 ;LEA AX, word ptr[EAX + 00000000]
!\{
!DB value
!\}
!end if
!if a=9
!irp value, $90, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=10
!irp value, $8B, $C0, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=11
!irp value, $66, $8D, $54, $22, $00, $8D, $80, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=12
!irp value, $66, $8D, $54, $22, $00, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=13
!irp value, $66, $8D, $54, $22, $00, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=14
!irp value, $8D, $80, $00, $00, $00, $00, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=15
!irp value, $8D, $04, $05, $00, $00, $00, $00, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!} ;End Macro
;========================================================================================
;- Test
Global TimeToRun.l = 5000
Global IntIterations.l
Global FpIterations.l
OpenConsole()
Timer.d = ElapsedMilliseconds()
IntIterations = 0
PrintN("Starting...")
Delay(20)
While ElapsedMilliseconds() < Timer + TimeToRun
IntA.l = 1234
IntB.l = 4321
IntIterations = IntIterations + 1
For i = 1 To 1000
iAns.l = IntA + IntB
iAns = IntA - IntB
iAns = IntB % IntA
iAns = IntA * IntB
IntA = IntA + i
IntB = IntB - i
Next
Wend
PrintN("Integer Iterations: " + Str(IntIterations))
Timer.d = ElapsedMilliseconds()
FpIterations = 0
Delay(100) ;let the cpus calm down
While ElapsedMilliseconds() < Timer + TimeToRun
!Blign 8
FPA.d = 1234.1234
FPB.d = 4321.4321
FpIterations = FpIterations + 1
For i = 1 To 1000
fAns.d = FPA + FPB
fAns = FPA - FPB
fAns = FPB / FPA
fAns = FPA * FPB
FPA = FPA + i
FPB = FPB - i
Next
Wend
PrintN("Floating Point Iterations: " + Str(FPIterations))
Input()
CloseConsole()
Code: Select all
SetPriorityClass_( GetCurrentProcess_(), #HIGH_PRIORITY_CLASS)
Global TimeToRun.l = 5000
Global IntIterations.l
Global FpIterations.l
OpenConsole()
Goto f
!SECTION '.testf' CODE READABLE EXECUTABLE ALIGN 4096
f:
IntIterations = 0
Timer.d = ElapsedMilliseconds()
While ElapsedMilliseconds() < Timer + TimeToRun
IntA.l = 1234
IntB.l = 4321
IntIterations = IntIterations + 1
For i = 1 To 1000
iAns.l = IntA + IntB
iAns = IntA - IntB
iAns = IntB % IntA
iAns = IntA * IntB
IntA = IntA + i
IntB = IntB - i
Next
Wend
PrintN("Integer Iterations: " + Str(IntIterations))
Delay(100) ;let the cpus calm down
Goto g
!SECTION '.testf' CODE READABLE EXECUTABLE ALIGN 4096
g:
FpIterations = 0
Timer.d = ElapsedMilliseconds()
While ElapsedMilliseconds() < Timer + TimeToRun
FPA.d = 1234.1234
FPB.d = 4321.4321
FpIterations = FpIterations + 1
For i = 1 To 1000
fAns.d = FPA + FPB
fAns = FPA - FPB
fAns = FPB / FPA
fAns = FPA * FPB
FPA = FPA + i
FPB = FPB - i
Next
Wend
PrintN("Floating Point Iterations: " + Str(FPIterations))
Goto f
Input()
CloseConsole()
End
I wrote a tool (bat file) to show the asm of any open file from the IDE. (Note: it does not use the compilation options like threadsafe.)pdwyer wrote:How do I view the ASM?
My ASM skills aren't good but I can read it enough to make some comparisons. (so I should be able to check the INT differences if there are any - which there shouldn't be.
Is there some switch in the compiler to dump the ASM code?
Code: Select all
@echo off
cd "c:\program files\purebasic\compilers"
pbcompiler %1 /COMMENTED %2
if errorlevel 1 goto wait
start PureBasic.asm
exit
:wait
pause
Code: Select all
;PB_DataPointer.l ;exist from PB
Global TimeToRun.l = 5000
Global IntIterations.l
Global FpIterations.l
Global IntA.l
Global IntB.l
Global iAns.l
Global Timer.l
Global i.l
Global X0.l ;Dummy
Global X1.l
Global X2.l ;with the dummys we have 12 longs
OpenConsole()
Timer.l = ElapsedMilliseconds()
IntIterations = 0
PrintN("Starting...Single")
Delay(20)
While ElapsedMilliseconds() < Timer + TimeToRun
IntA.l = 1234
IntB.l = 4321
IntIterations = IntIterations + 1
For i = 1 To 1000
iAns.l = IntA + IntB
iAns = IntA - IntB
iAns = IntB % IntA
iAns = IntA * IntB
IntA = IntA + i
IntB = IntB - i
Next
Wend
PrintN("Integer Iterations: " + Str(IntIterations))
Timer.l = ElapsedMilliseconds()
FpIterations = 0
Delay(100) ;let the cpus calm down
While ElapsedMilliseconds() < Timer + TimeToRun
FPA.f = 1234.1234
FPB.f = 4321.4321
FpIterations = FpIterations + 1
For i = 1 To 1000
fAns.f = FPA + FPB
fAns = FPA - FPB
fAns = FPB / FPA
fAns = FPA * FPB
FPA = FPA + i
FPB = FPB - i
Next
Wend
PrintN("Floating Point Iterations: " + Str(FPIterations))
Input()
CloseConsole()
Code: Select all
;PB_DataPointer.l ;exist from PB
Global X0.l ;Dummy
Global TimeToRun.l = 5000
Global IntIterations.l
Global FpIterations.l
Global IntA.l
Global IntB.l
Global iAns.l
Global Timer.l
Global i.l
Global X1.l
Global X2.l ;with the dummys we have 12 longs
OpenConsole()
Timer.l = ElapsedMilliseconds()
IntIterations = 0
PrintN("Starting...Double")
Delay(20)
While ElapsedMilliseconds() < Timer + TimeToRun
IntA = 1234
IntB = 4321
IntIterations = IntIterations + 1
For i = 1 To 1000
iAns = IntA + IntB
iAns = IntA - IntB
iAns = IntB % IntA ;Modulo or Div?
iAns = IntA * IntB
IntA = IntA + i
IntB = IntB - i
Next
Wend
PrintN("Integer Iterations: " + Str(IntIterations))
Timer = ElapsedMilliseconds()
FpIterations = 0
Delay(100) ;let the cpus calm down
While ElapsedMilliseconds() < Timer + TimeToRun
FPA.d = 1234.1234
FPB.d = 4321.4321
FpIterations = FpIterations + 1
For i = 1 To 1000
fAns.d = FPA + FPB
fAns = FPA - FPB
fAns = FPB / FPA
fAns = FPA * FPB
FPA = FPA + i
FPB = FPB - i
Next
Wend
PrintN("Floating Point Iterations: " + Str(FPIterations))
Input()
CloseConsole()
Code: Select all
#SubOpCount = 1000
Global gIterations.l
Global MtxIterates.l
Declare.l CryptSpeed(MilliSecondsToRun)
Declare Main()
MtxIterates = CreateMutex()
Main()
Procedure Main()
OpenConsole()
PrintN("Starting...")
TimeToRun.l = 2000
CreateThread(@CryptSpeed(),TimeToRun)
Delay(TimeToRun + 200)
PrintN("Single thread iterations: " + Str(gIterations))
TmpIterations = gIterations
Delay(20)
gIterations = 0
For i = 1 To 8
CreateThread(@CryptSpeed(),2000)
Delay(20)
Next
Delay(2000 + 1000)
PrintN("8 Thread iterations: " + Str(gIterations))
PrintN("Difference: "+ StrF((gIterations/TmpIterations * 100) -100,2) + "%" )
PrintN("Done!")
Input()
CloseConsole()
EndProcedure
Procedure CryptSpeed(MilliSecondsToRun.l)
*Buffer = AllocateMemory(1024)
Protected IterationCount.l = 0
Protected Timer.l = ElapsedMilliseconds()
While ElapsedMilliseconds() < Timer + MilliSecondsToRun
IterationCount = IterationCount + 1
For i = 0 To 1023
PokeB(*Buffer + i,i % 255)
Next
Result = CRC32Fingerprint(*Buffer, 1024)
Results.s = MD5Fingerprint(*Buffer, 1024)
Results.s = DESFingerprint(PeekS(*Buffer), PeekS(*Buffer))
Wend
FreeMemory(*Buffer)
LockMutex(MtxIterates)
gIterations = gIterations + IterationCount
UnlockMutex(MtxIterates)
EndProcedure