When I was recently working on a project where I was trying to measure performance of something else while displaying visuals, I realized something strange is going on.
After about ten seconds of execution, there is a noticable drop in the rate of certain kinds of graphics operations.
In this case, I'm drawing a lot of filled circles on the screen, switching buffers ten times a second. For the first ten seconds my machine manages ~4300 circles per 100ms frame, thereafter only managing around 2700 circles per frame. (This is without debug enabled, although the behavior is present and similar with debug enabled albeit with smaller counts)
I'm able to replicate this result whether or not I have #PB_Screen_NoSynchronization set for the window, and regardless of the timestep I use per frame (every 100ms, every 500ms, every 1000ms).
Strangely, this does NOT occur with lineXY(), but it does occur with box() (the below commented-out instruction for boxes goes about 76 per 100ms frame for the first 10 seconds, then about 44 per 100ms frame thereafter.
If I change which graphics operation I am performing after 10 seconds, I get results commensurate with just using that operation only from start to past 10 seconds. If I switch from boxes or circles for ~11-12 seconds to lines, lines perform just as normal with no apparent slowdown.
This particular set of tests was done on windows PB5 x86 (final), but in the past I've seen it on windows PB 4.x x64.
Can anyone help me track this down?
Code: Select all
OpenWindow(0,50,50,640,480,"test")
InitSprite()
InitKeyboard()
OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)
starttime.i=ElapsedMilliseconds()
time = starttime
circlecount = 0
totalcount = 0
framecount = 0
Repeat
Gosub processevents
oldtime = time
circlecount = 0
FlipBuffers()
framecount + 1
ClearScreen(0)
StartDrawing(ScreenOutput())
Repeat
time = ElapsedMilliseconds() - starttime
Circle(400, 400, 5)
;LineXY(0, 400, 400, 0)
;Box(0,0, 400, 400)
; If time - startime < 12000
; Box(0,0, 400, 400)
; Else
; LineXY(0, 400, 400, 0)
; Circle(400, 400, 5)
; EndIf
circlecount + 1
totalcount + 1
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
exit = 1
EndIf
Until time > oldtime + 100 Or exit
DrawText(0,0,Str(time) + " : " + Str(circlecount) + " , " + Str(totalcount) + " ( " + Str(framecount)+")")
StopDrawing()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
exit = 1
EndIf
Until exit ; time >= 3.5 Or
Repeat
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or exit
End
processevents:
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
exit = 1
EndSelect
Return