Benchmark PB

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Benchmark PB

Post by Kwai chang caine »

Hello at all

I want to test and compare all my machines :idea:
I have see there are several freeware softwares (Everest, Geekbench, ...) for do that, but the result is often very hard to analyse, too much informations for me :oops:
Do you believe, it's interesting to do that with PB, for just have a simple result (Read/write drive, Read/write memory, calculations, etc ...) or know you a very simple freeware for do this job

Have a good day
ImageThe happiness is a road...
Not a destination
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

Hello

You need to make all sorta of algorithms to test the speed for PB with loops, search algorithm and data structure in google and there are a lot of plenty infromation to create a small program written by you :)

Not sure if there are someone can code a benchmark for you ? :?

And have a nice day to you too ;)
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Benchmark PB

Post by Tenaja »

There is a web site that compares benchmarks of many languages & compilers called the compiler game or something like that. It would be perfect to translate that C code into PB, as you could also compare THE benchmark, C, on the same machine.

https://benchmarksgame-team.pages.debia ... est/c.html
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

Ok I have created a similar a benchmark maybe it is not good one but you can have a view of something the speed :)

Here my code :

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Created by threedslider 01/31/2024
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Procedure _2D_Rectangle_shape(x1, y1, x2, y2, r1, g1, b1)
   StartDrawing(ScreenOutput())
   For y = y1 To y2
     For x = x1 To x2       
       Plot(x,y,RGB(r1, g1, b1))
     Next
   Next
  StopDrawing()
EndProcedure



Procedure _2D_Rectangle_benchmark(r, g, b)
  
  randUp1 = Random(790)
  randUp2 = Random(590) 
  randDown1 = Random(790) 
  randDown2 = Random(590) 
  
  bg_r = r
  bg_g = g
  bg_b = b
  
    _2D_Rectangle_shape(randUp1, randUp2, randDown1, randDown2, bg_r, bg_g, bg_b)
 
EndProcedure



InitSprite()
InitKeyboard()

OpenWindow(1, 0,0,800,600,"2d rectangle shape benchmark", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)


  ClearScreen(RGB(0,0,0))
  
  stop = 0
  color_change = 1
   

Repeat
  ExamineKeyboard()
  
  stop = stop + 1
  
  color_change = color_change + 1
  
  event = WindowEvent()
  
  If color_change > 0 And color_change < 255
    _2D_Rectangle_benchmark(255-color_change, 0+color_change, 255-color_change ) 
  Else
    If color_change >= 255
    color_change = 0
    color_change = color_change + 1
    _2D_Rectangle_benchmark(0+color_change, 255-color_change, 0+color_change ) 
    EndIf 
  EndIf
  
  time.q = ElapsedMilliseconds()
  
  FlipBuffers()
  
  Debug time/1000
  
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape) Or stop = 1000
End
You need to compile in debugger you view in time which take it.

So mine it took 8 seconds and you ?
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Benchmark PB

Post by Fred »

The event loop is wrong, you need to process all the messages at every frame:

Code: Select all

Repeat
  event= windowevent()
  ; do you event code here
Until event=0
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

Fred wrote: Tue Jan 30, 2024 9:03 am The event loop is wrong, you need to process all the messages at every frame:

Code: Select all

Repeat
  event= windowevent()
  ; do you event code here
Until event=0
Thank you Fred for pointed this.
Alright, so I have disabled the event by

Code: Select all

; event= windowevent()
and it tooks now 6 sec, is it real time now ?
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Benchmark PB

Post by Fred »

You need to disable VWait with #PB_Screen_NoSynchronization if you want maximum troughput. That's wierd, event loop shouldn't impact perf at all.
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

Yes with #PB_Screen_NoSynchronization is a way better for perfomance it tooks now 4 seconds :)

Event loop is quite fast but not fast as alone, you think any possible to improve the loop in your dev ?

Thanks ! PB is awesome :P
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Benchmark PB

Post by Kwai chang caine »

Hello threedslider :D

Excuse me for the late answer :oops: i not receive the mail notification of your answer :|
Not sure if there are someone can code a benchmark for you ? :?
It's not my goal :wink:
I wanted just have advice of MASTERS on my idea, and may be links of freewares, simple to read their results
Also have advice about possibility with my little knowledge to accomplish this task :wink:
Obviously, i'm not against receive pieces of code for help me in this little project :mrgreen: like you give to me 8)

Thanks a lot for you nice code 8)
For good understand, your code test what exactely ?

The rapidity of :
1/ Graphic card ?
2/ Memory ?
3/ Other component of the machine ?

@FRED
Thanks too, for your precious help :wink:
ImageThe happiness is a road...
Not a destination
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

Hello :)

It is a calculation of speed for drawing with a lot of rectangles from scratch using the function plot with pixel by pixel so I have generated from different size to this shape at different location and different color. This code show a generated of 1000 shapes of rectangle with loop as repeat. So what does mean the speed? It means when it generates a lot of shapes the better is less in time of calculation thus if it takes more time the bad is it. It is a machine with cpu make a task for a measure of speed of calculation given by PB to my code and my code is an example on how make your as benchmark application :)

That is all.

If you have question on more how to make it, ask us ;)

Of course, you can perform the speed from, memory, graphic, algorithm, etc…
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Benchmark PB

Post by Kwai chang caine »

Thanks a lot for your precious explanation 8)

After your nice code, I don't know if it's the good way :oops: but i can now, try to test the memory

Code: Select all

TimeStart = ElapsedMilliseconds() 

For i = 1 To 10000
 
 *Ptr = AllocateMemory(i * 2)
 Sentence$ = RSet("", i, "*")
 PokeS(*Ptr, Sentence$, i, #PB_Ascii)
 ;Debug PeekS(*Ptr, i, #PB_Ascii)
 FreeMemory(*Ptr)
 
Next

Debug StrF((ElapsedMilliseconds() - TimeStart) / 1000) + " seconds"
And try to test a hard drive

Code: Select all

Drive.s = "c:\"
TimeStart = ElapsedMilliseconds()
Folder.s = FormatDate("%yy%mm%dd", Date()) + FormatDate("%hh%ii%ss", Date())
FileTest$ = Drive + Folder + "\"
SHCreateDirectory_(#Null, FileTest$) 
Canal = CreateFile(#PB_Any, FileTest$ + "\Test")

If Canal
 
 For i = 1 To 100000
  WriteStringN(Canal, RSet("", i, "*"), #PB_Ascii)
 Next
  
 CloseFile(Canal)
 
 If Not DeleteDirectory(GetPathPart(FileTest$), "*.*", #PB_FileSystem_Recursive|#PB_FileSystem_Force)
  MessageRequester("Error", "The folder test can't be deleted.")
 EndIf 
  
Else

 MessageRequester("Error", "The file test can't be created.")
      
EndIf

Debug StrF((ElapsedMilliseconds() - TimeStart) / 1000) + " seconds"
ImageThe happiness is a road...
Not a destination
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

Nice starting :)

But not sure if this is one good way but I do a little modification as here :

Code: Select all

TimeStart = ElapsedMilliseconds() 

For i = 1 To 10000
 
 *Ptr = AllocateMemory(i * 2)
 Sentence$ = RSet("", i, "*")
 PokeS(*Ptr, Sentence$, i, #PB_Ascii)
 ;Debug PeekS(*Ptr, i, #PB_Ascii)
 FreeMemory(*Ptr)
 Debug StrF((ElapsedMilliseconds() - TimeStart) / 1000) + " seconds"
 
Next
The output is not shown the same here, maybe more corret, right ? Because it perform the time speed inside of loop to "For" ( :!: )...
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

... Ok I think all your codes are good and i may be wrong mine :)
threedslider
Enthusiast
Enthusiast
Posts: 434
Joined: Sat Feb 12, 2022 7:15 pm

Re: Benchmark PB

Post by threedslider »

A test for 2D arrays for one millions arrays :shock: ! (Need to compile in x64)

Code: Select all

TimeStart = ElapsedMilliseconds() 

Dim tab(1000,1000)

For i = 0 To 1000-1
  For ii = 0 To 1000-1
 
 	tab(i,ii) = i * 2 + 5 + ii

  Next
Next

FreeArray(tab())

Debug StrF((ElapsedMilliseconds() - TimeStart) / 1000) + " seconds"

Debug tab()
Very fast ! :mrgreen:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Benchmark PB

Post by Kwai chang caine »

Incredible !!!! :shock:
0.0560000017 seconds
Thanks a lot for your new code 8)

Image

and HOP.....in my basket 8)

@TENAJA
Excuse me for not answer to your message, i see it only now :oops:
So...later i thanks you very much for your nice link 8)
ImageThe happiness is a road...
Not a destination
Post Reply