Fixed some more bugs...
New Version

Has some more features and some fixes.
My PC outputs this:
Starting...
Single thread iterations: 19468
24 Thread iterations: 172203
Difference Multiplier: 8.85x
Cached Disk Writes: 17085
Disk Reads: 897605
2D Graphics iterations: 27463
Done!
My PC with as a 2cpu VM has this
Starting...
Single thread iterations: 14449
24 Thread iterations: 59799
Difference Multiplier: 4.14x
Cached Disk Writes: 10026
Disk Reads: 567543
2D Graphics iterations: 9971
Done!
Needs threadsafe compile option on still... please throw at me any painfully obvious flaws, I'm sure there's plenty
Code: Select all
Global gIterations.l
Global MtxIterates.l
Declare.l CryptSpeed(MilliSecondsToRun)
Declare GFXTest(MillisecondsToRun.l)
Declare DiskWriteSpeed(MilliSecondsToRun.l)
Declare DiskReadSpeed(MilliSecondsToRun.l)
Declare Main()
MtxIterates = CreateMutex()
Main()
Procedure Main()
OpenConsole()
PrintN("Starting...")
TimeToRun.l = 3000
ThreadCount = 24
CreateThread(@CryptSpeed(),TimeToRun)
Delay(TimeToRun + 200)
PrintN("Single thread iterations: " + Str(gIterations))
TmpIterations = gIterations
Delay(20)
gIterations = 0
For i = 1 To ThreadCount
CreateThread(@CryptSpeed(),TimeToRun)
Delay(20)
Next
Delay(TimeToRun + 500)
PrintN(Str(ThreadCount) + " Thread iterations: " + Str(gIterations))
PrintN("Difference Multiplier: "+ StrF((gIterations/TmpIterations ),2) + "x")
Delay(200)
DiskWriteSpeed(TimeToRun)
PrintN("Cached Disk Writes: " + Str(gIterations))
Delay(200)
DiskReadSpeed(TimeToRun)
PrintN("Disk Reads: " + Str(gIterations))
Delay(200)
CreateThread(@GFXTest(),TimeToRun)
Delay(TimeToRun + 200)
PrintN("2D Graphics iterations: " + Str(gIterations))
PrintN("Done!")
Input()
CloseConsole()
EndProcedure
Procedure CryptSpeed(MilliSecondsToRun.l)
BufferSize.l = 10240
*Buffer = AllocateMemory(BufferSize)
Protected IterationCount.l = 0
Protected Timer.l = ElapsedMilliseconds()
While ElapsedMilliseconds() < Timer + MilliSecondsToRun
IterationCount = IterationCount + 1
For i = 0 To BufferSize -1
PokeB(*Buffer + i,i % 255)
Next
Result = CRC32Fingerprint(*Buffer, BufferSize)
Results.s = MD5Fingerprint(*Buffer, BufferSize)
Results.s = DESFingerprint(PeekS(*Buffer), PeekS(*Buffer))
Wend
FreeMemory(*Buffer)
LockMutex(MtxIterates)
gIterations = gIterations + IterationCount
UnlockMutex(MtxIterates)
EndProcedure
Procedure DiskWriteSpeed(MilliSecondsToRun.l)
BufferSize.l = 10240
MaxFileSize.q = 10 * 1000 * 1024
Filename.s = "c:\benchtempfile.tmp"
*Buffer = AllocateMemory(BufferSize)
Protected IterationCount.l = 0
Protected Timer.l = ElapsedMilliseconds()
hfile.l = CreateFile(#PB_Any, Filename)
;FileBuffersSize(hfile, 0)
While ElapsedMilliseconds() < Timer + MilliSecondsToRun
IterationCount = IterationCount + 1
For i = 0 To BufferSize -1
PokeB(*Buffer + i,Random(255))
Next
FileSeek(hfile, Random(MaxFileSize) + 1)
WriteData(hfile, *Buffer, BufferSize)
Wend
CloseFile(hfile)
DeleteFile(Filename)
FreeMemory(*Buffer)
gIterations = IterationCount
EndProcedure
Procedure DiskReadSpeed(MilliSecondsToRun.l)
BufferSize.l = 1024000
MaxFileSize.q = 10 * 1000 * 1024
Filename.s = "c:\benchtempfile.tmp"
*Buffer = AllocateMemory(BufferSize)
Protected IterationCount.l = 0
hfile.l = CreateFile(#PB_Any, Filename)
FileBuffersSize(hfile, 0)
;build file
*WriteBuffer = AllocateMemory(MaxFileSize)
For i = 1 To MaxFileSize
PokeB(*WriteBuffer + i,Random(255))
Next
WriteData(hfile,*WriteBuffer,MaxFileSize)
FreeMemory(*WriteBuffer)
CloseFile(hfile)
Protected Timer.l = ElapsedMilliseconds()
hfile.l = CreateFile(#PB_Any, Filename)
While ElapsedMilliseconds() < Timer + MilliSecondsToRun
IterationCount = IterationCount + 1
FileSeek(hfile, Random(MaxFileSize-BufferSize) + 1)
ReadData(hfile, *Buffer, Random(BufferSize))
Wend
CloseFile(hfile)
DeleteFile(Filename)
FreeMemory(*Buffer)
gIterations = IterationCount
EndProcedure
Procedure GFXTest(MillisecondsToRun.l)
If OpenWindow(0, 100, 100, 640, 480, "Purebench32 Graphics test", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget)
SetActiveWindow(0)
StickyWindow(0, 1)
StartDrawing(WindowOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
LoadFont(1, "Arial", 22)
DrawingFont(FontID(1))
Protected Timer.l = ElapsedMilliseconds()
While ElapsedMilliseconds() < Timer + MilliSecondsToRun
IterationCount = IterationCount + 1
Rnd1 = Random(500)+1
Rnd2 = Random(500)+1
rnd3 = Random(16000000)
Box(Rnd2,Rnd1,Rnd2/2,Rnd1/2,rnd3)
Circle(Rnd1, Rnd2, Rnd2/5,rnd3 / 2)
DrawText(Rnd2, Rnd1, "PureBench32" , rnd3 /4)
Wend
StopDrawing()
EndIf
gIterations = IterationCount
EndProcedure