Inline profiler v0.1

BlitzMax Forums/BlitzMax Programming/Inline profiler v0.1

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You can use QueryPerformanceCounter on Windows to get more accurate time information. Windows code below - I am not sure what the Linux and Mac equivilents are:


Framework BRL.GLMax2D
Import BRL.PNGLoader

Extern "Win32"
       Function QueryPerformanceFrequency:Int(freqency:Long Ptr)
       Function QueryPerformanceCounter:Int(frequency:Long Ptr)
End Extern

Graphics 1024,768,0

image:TImage=LoadImage("graphics/ship_light.png")

SetScale 0.1,0.1

Global gameSpeed:Long=0
Global oldGameSpeed:Long=0

r=QueryPerformanceFrequency(Varptr gameSpeed)

QueryPerformanceCounter(Varptr oldGameSpeed)

Global fps:Long
Global totalFps:Long=0
Global totalR:Long=0

Repeat

       For x=0 To 20
               For y=0 To 20
                       DrawImage image,x*50,y*50
                       SetRotation rotate
                       rotate :+ 3
               Next
       Next

       Flip

       Cls

       fps=(gameSpeed-oldGameSpeed)/100
       oldGameSpeed=gameSpeed

       QueryPerformanceCounter(Varptr gameSpeed)

       totalR = totalR+1

       If (totalR > 50)

       totalFps :+ fps

       EndIf
Until KeyHit(KEY_ESCAPE)

       Print (totalFps/(totalR-50))

EndGraphics