Purebench32 v1 ready, need some help still

Everything else that doesn't fall into one of the other PB categories.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Purebench32 v1 ready, need some help still

Post by pdwyer »

Okay, here is an attempt at a simple benchmark tool, using it on different systems seems to show it to be meaningful.

I'm still looking for a simple 3D test, some graphic which is GPU but not as CPU intensive were I can measure the frame rate, any ideas please post! I was thinking of something like the openGL cube example....

I'm also looking for an idea for a memory speed test, I was thinking of lots of alloc, frees and copies but I'm not sure if that will end up just being a CPU test...

Output screen now looks like this

Code: Select all

=====================================================================
|                         PureBench32  v1.0                         |
|                           by Paul Dwyer                           |
|                        and the PB community                       |
=====================================================================

CPU Tests:
    Single thread score:         32514
    Multi thread iterations:    174669
    Multi thread perf increase:  5.37x

Disk:
    Cached Disk Writes:           1558
    Disk Reads:                  69361

Grphics:
    2D Graphics Score:           44071
The /? help options look like this...

Code: Select all

Global gIterations.l
Global MtxIterates.l
Global TimeToRun.l 
Global ThreadCount.l
Global Diskpath.s
Global CloseOnEnd.l

Declare CryptSpeed(MilliSecondsToRun) 
Declare GFXTest(MillisecondsToRun.l)
Declare DiskWriteSpeed(MilliSecondsToRun.l, NoCache.l = #False)
Declare DiskReadSpeed(MilliSecondsToRun.l)
Declare.s GetCMDParam(Param.s) 
Declare.l GetCMDSwitch(Switch.s) 

Declare Main()

MtxIterates = CreateMutex()
Main()

Procedure.s GetCMDParam(Param.s) 

    Param = LCase(Param) 
    
    For i = 0 To CountProgramParameters() -1 
        If  LCase(ProgramParameter(i)) = Param 
            ProcedureReturn ProgramParameter(i+1) 
        EndIf    
    Next    

    ProcedureReturn "" 
    
EndProcedure 


Procedure.l GetCMDSwitch(Switch.s) 

    Switch = LCase(Switch) 
    
    For i = 0 To CountProgramParameters() -1
        If  LCase(ProgramParameter(i)) = Switch 
            ProcedureReturn #True 
        EndIf    
    Next    

    ProcedureReturn #False    

EndProcedure 


Procedure Main()
    
    ;startup

    Displayheader.s = "=====================================================================" + #CRLF$
    Displayheader.s = Displayheader.s + "|                         PureBench32  v1.0                         |" + #CRLF$
    Displayheader.s = Displayheader.s + "|                           by Paul Dwyer                           |" + #CRLF$
    Displayheader.s = Displayheader.s + "|                        and the PB community                       |" + #CRLF$
    Displayheader.s = Displayheader.s + "=====================================================================" + #CRLF$
    
    OpenConsole()
        
        If GetCMDSwitch("/?") = #True ; Display help
        
            PrintN(Displayheader)
            PrintN("")
            PrintN("/t    Time   (seconds to run per task, default = 5)")
            PrintN("/p    Path   (location for disk read and write checks default = C:\)")
            PrintN("/tc   Count  (thread count to use for multiple threads default = 24)")
            PrintN("/c    (close on finish, if not set then the dos screen will wait for a return key to end)")
            PrintN("/?    (this help information)")
            Input()
            End
        
        EndIf
        
        CloseOnEnd = GetCMDSwitch("/c")
        TimeToRun = Val(GetCMDParam("/t"))
        If TimeToRun = 0: TimeToRun = 5000: EndIf
        
        ThreadCount = Val(GetCMDParam("/tc"))
        If ThreadCount = 0: ThreadCount = 24: EndIf
        
        Diskpath = GetCMDParam("/p")
        If Len(Diskpath) < 1: Diskpath = "C:\": EndIf
        If Right(diskpath,1) <> "\": Diskpath = Diskpath + "\": EndIf

        ;EnableGraphicalConsole(1)
   
        PrintN(Displayheader)

        PrintN("CPU Tests:")
        CreateThread(@CryptSpeed(),TimeToRun)
        Delay(TimeToRun + 100)
        
        PrintN("    Single thread score:         " + Str(gIterations))
        TmpIterations = gIterations
        Delay(20)

        gIterations = 0 
        
        For i = 1 To ThreadCount
            CreateThread(@CryptSpeed(),TimeToRun)
            Delay(20)
            
        Next
        
        Delay(TimeToRun + 500)
                
        PrintN("    Multi thread score:         " + Str(gIterations))
        PrintN("    Multi thread perf increase:  "+ StrF((gIterations/TmpIterations ),2) + "x")
        
        Delay(200)
        
        
        PrintN("")
        PrintN("Disk:")
        DiskWriteSpeed(TimeToRun, #True)
        PrintN("    Non Cached Disk Writes:       " + Str(gIterations))
               
        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("")
        PrintN("Grphics:")
        PrintN("    2D Graphics Score:           " + Str(gIterations))
        
        If CloseOnEnd = #False
            Input()
        EndIf
    
    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)
    ;MessageRequester("",Str(GetCurrentThreadId_()))
    LockMutex(MtxIterates)
    gIterations = gIterations + IterationCount
    UnlockMutex(MtxIterates)
    
EndProcedure


Procedure DiskWriteSpeed(MilliSecondsToRun.l, NoCache.l = #False)

    BufferSize.l = 500 * 1024
    MaxFileSize.q = 10 * 1000 * 1024
    Filename.s = Diskpath + "benchtempfile.tmp"
    
    Debug Filename
    
    *Buffer = AllocateMemory(BufferSize)
    Protected IterationCount.l = 0
    Protected Timer.l = ElapsedMilliseconds()
       
    hfile.l = CreateFile(#PB_Any, Filename) 

    For i = 0 To BufferSize -1
        PokeB(*Buffer + i,Random(255))
    Next
    
    If IsFile(hfile)
              
        While ElapsedMilliseconds() < Timer + MilliSecondsToRun  
            IterationCount = IterationCount + 1
            FileSeek(hfile, Random(MaxFileSize - 1) + 1)
            WriteData(hfile, *Buffer, BufferSize)    
            If NoCache = #True
                FlushFileBuffers(hfile)
            EndIf       
         Wend
        
        CloseFile(hfile) 
        DeleteFile(Filename)
    
    EndIf
    FreeMemory(*Buffer)
    gIterations = IterationCount

EndProcedure


Procedure DiskReadSpeed(MilliSecondsToRun.l)

    BufferSize.l =   500 * 1024 
    MaxFileSize.q = 10 * 1000 * 1024
    Filename.s = Diskpath + "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 = OpenFile(#PB_Any, Filename)
    
    If IsFile(hfile)
    
        While ElapsedMilliseconds() < Timer + MilliSecondsToRun  
            
                IterationCount = IterationCount + 1
                FileSeek(hfile, Random(MaxFileSize-BufferSize) + 1)
                ReadData(hfile, *Buffer, Random(BufferSize))
                      
        Wend
        
        CloseFile(hfile) 
        DeleteFile(Filename)
    
    EndIf
    
    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) 
        
        LoadFont(1, "Arial", 22)
        
            
        StartDrawing(WindowOutput(0)) 
            DrawingMode(#PB_2DDrawing_Transparent)  
            DrawingFont(FontID(1)) 
             
            Protected Timer.l = ElapsedMilliseconds()
             
            While ElapsedMilliseconds() < Timer + MilliSecondsToRun
            
                IterationCount = IterationCount + 1

                Box(Random(500)+1,Random(500)+1,Random(500)/3,Random(500)/3,Random(16777216))
                Circle(Random(500)+1, Random(500)+1, Random(500)/5,Random(16777216)) 
                DrawText(Random(450)+1, Random(450)+1, "PureBench32" , Random(16777216))
                               
            Wend
    
        StopDrawing() 
   
    EndIf

    gIterations =  IterationCount

EndProcedure


comments and criticisms welcome, constructive is preferable but I'll take what I can get :)
Last edited by pdwyer on Sat Oct 18, 2008 1:05 pm, edited 2 times in total.
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

Just blindly ran your code pdwyer.
Had a couple of stoppages.
1. line 143, error = declare doesn't match with real procedure. - fixed by dropping the".l" from the proc parametre
2. line 191, "FileSeek(hfile,Random(MaxFileSize)-1 )", error = cannot seek beyond end of the file - did a temp to make it run which will most probably throw your test out of whack as "FileSeek(hfile,Eof(hFile)-1)"
3. line 253, error = loadfont() cant be called inside a start/stop drawing block. - Just moved loadfont above startdrawing.

Hope this helps.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Thanks for this

What version of PB are you using? I've run this so many times it's not funny and I'm sure I'd hit these basic ones...

I'm using 4.20

Are you using a beta and it's stricter?

No1, fair enough but 4.20 doesn't catch that
No2, deliberate on my part, not too happy there :?
No3, guess it's just a change

Edit: No2, isn't deliberate after all, I had the debugger turned off to run tests (of course :) ) I'm trying to think whether to modify the code or just say leave the dubugger off.
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Fixed 1 and 3 in the code above.
Number 2 I'm thinking about, turn the debugger off for the moment and it will run fine. Its a benchmark tool so the debugger should be off to run anyway. The file does write out and work as planned, this must be some warning only?
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Demivec
Addict
Addict
Posts: 4283
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Wouldn't you want to isolate the calls to Random() outside of the timed sections? I remember that calling Random() frequently would affect thread timing, if I understood correctly. I have no data to back this up, just the comment by freak in your other forum thread.

I'm using an AMD Atholon 64 3500+ 2.21GHz 2GB Ram; Nvidia GeForce 6600; Windows XP SP3; PureBasic v4.30b3.

Here are my test results:

Code: Select all

=====================================================================
|                         PureBench32  v1.0                         |
|                           by Paul Dwyer                           |
|                        and the PB community                       |
=====================================================================

CPU Tests:
    Single thread score:         12357
    Multi thread iterations:    34148
    Multi thread perf increase:  2.76x

Disk:
    Cached Disk Writes:           275
    Disk Reads:                  79131668

Grphics:
    2D Graphics Score:           94038
The results for Disk Reads seem a little high compared with yours.
Last edited by Demivec on Sat Oct 18, 2008 3:07 am, edited 2 times in total.
User avatar
GeoTrail
Addict
Addict
Posts: 2799
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

It crashes on my computer.
After the CPU test is done, the result is displayed really quickly then the program ends with an error from Vista saying the program has stopped working. Same result when running it in the PB IDE and as a compiled console app.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

@Demivec I took the random calls out of the multi thread check as that's where it was causing problems. having them in the other areas or not didn't noticably effect performance at all. Cheers for your stats, you 2d stats whip mine, what card do you have ( want to be sure it's the card and not the CPU effecting that number). Your disk scores were interesting too, wonder what causes such a big difference

@Geotrail Are you sure you have threadsafe mode set? If so I'll need to test in vista, I have a VM around somewhere. I get a crash if threadsafe is not set due to the crypt functions in the CPU section.

If you are using vmware or MSTS or some other interface to the system you run this on then the 2d gfx score will be out. sometimes very high (in msts) or low (vm)
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

Soz for not answering sooner Paul, I ran this @ 1.30am this morning just prior to going to bed, so I have just had a great 10hr sleep... :lol:
So, yes, I ran it on 4.3B3 ( I just was not thinking at that time about having the beta running which does complain a fair bit more than the stable 4.2.)
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Baldrick wrote:Soz for not answering sooner Paul, I ran this @ 1.30am this morning just prior to going to bed, so I have just had a great 10hr sleep... :lol:
So, yes, I ran it on 4.3B3 ( I just was not thinking at that time about having the beta running which does complain a fair bit more than the stable 4.2.)
Actually you were right on a few, I just had the debugger turned off and they were errors that only complained when the debugger is enabled. I didn't realise that there were errors like that

Cheers :)
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

My results using 4.2 with debugger disabled, etc.

Code: Select all

=====================================================================
|                         PureBench32  v1.0                         |
|                           by Paul Dwyer                           |
|                        and the PB community                       |
=====================================================================

CPU Tests:
    Single thread score:         19880
    Multi thread iterations:    41262
    Multi thread perf increase:  2.08x

Disk:
    Cached Disk Writes:           299
    Disk Reads:                  23813

Grphics:
    2D Graphics Score:           59629
3Ghz HTT cpu, 512MB Ram, GeForce FX5200 Graphics with 128MB RAM
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Thanks, are you using sata II disks? or Sata I or IDE? I'm wondering where the difference in write speed is coming from.
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

IDE disk here. Which is showing as dual channel ide in my system.
System also is showing me as having dual 3Ghz cpu's
(I must pull this machine apart 1 day to see what I have actually got.. :oops:
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Is that a pre core-duo hyper threading CPU? They were about the same as an Athlon 2ghz dual core. Intel was losing the plot back then and thought people would just read the Ghz rating and not worry that the AMDs were getting almost twice the instructions per clock cycle. Then the core duos came out and intel was back in the race the they were real multi core chips. A 2.5ghz core duo will run a lot faster than a 3.2ghz hyper threaded chip. AMD has since started to lose the plot a little which is a shame

Assuming I've guessed your CPU correctly, I think the benchmark is correctly showing it's performance. My PC at work is a core 2 due and performs a little lower than home for the single thread, about 3-4x on the 24thread run. The quad on my home PC runs at about 6-7x
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

pdwyer wrote:Assuming I've guessed your CPU correctly
You got it spot on.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

8) That would also explain the x2 rating for multi threading, they were not "real" dual cores in the sense that there are dual cores today from both vendors
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Post Reply