Execution Speed: a striking observation on my PC!
Posted: Sat Oct 29, 2005 6:56 pm
				
				Here a program which displays a series of sprites on the screen at each loop and indicates the elapse time spend.
If I carry out the program 2 times, without removing them, I note that the elapse time spend by the second instance is shorter than the first one.
Why ??!!!
Is it the same observation for you?
Caution: It is clear that the performance depend largely on the computer configuration. Probably with current standard conf, you do not see anything, but with my poor PIII 500 and Win98, I feel a clear difference: I have a factor 20 to 200!
It is probably a problem of memory management. But I cannot say if it is a Win98 or a PB problem.
It is very uncomfortable for the gameplay of my game in which I refreshed the map each loop.
 
Moreover, it is especially an intrinsically inextricable situation.
 
Does somebody have an explanation and a solution?
Second edition: I have put a Delay(100)
			If I carry out the program 2 times, without removing them, I note that the elapse time spend by the second instance is shorter than the first one.
Why ??!!!
Is it the same observation for you?
Caution: It is clear that the performance depend largely on the computer configuration. Probably with current standard conf, you do not see anything, but with my poor PIII 500 and Win98, I feel a clear difference: I have a factor 20 to 200!
It is probably a problem of memory management. But I cannot say if it is a Win98 or a PB problem.
It is very uncomfortable for the gameplay of my game in which I refreshed the map each loop.
Moreover, it is especially an intrinsically inextricable situation.
Does somebody have an explanation and a solution?
Code: Select all
InitSprite()
  #Width=32
  #Height=32
  #WindowWidth=22*#Width
  #WindowHeight=14*#Height
  #NbDisplaySprite = #WindowWidth/#Width * #WindowHeight/#Height
  #NbSprite = #NbDisplaySprite
  
  If OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "Boxes") And OpenWindowedScreen(WindowID(), 0, 0, #WindowWidth, #WindowHeight, 0, 0, 0)
    AddKeyboardShortcut(0,#PB_Shortcut_F1, #PB_Shortcut_F1)
    
    For k = 0 To #NbSprite-1
    CreateSprite(k, #Width, #Height, #PB_Sprite_Memory)
      If StartDrawing(SpriteOutput(k)); Dessine le Sprite
        y = 0
        #StepX = 2
        StepY = Round(#StepX*#Height/#Width, 0)
        For x = 0 To #Width/2 Step #StepX
          Box(x, y, #Width-2*x, #Height-2*y ,RGB(Random(255),Random(255),Random(255)))
          y + StepY
        Next x
        ;Locate(#Width/3, #Height/3) : DrawText(Str(k))
        StopDrawing()
      EndIf
    
    Next
    
    ;Affichage des sprites
    Repeat
      k=0
      tps = GetTickCount_()
      For x = 0 To #WindowWidth-1 Step #Width
        For y= 0 To #WindowHeight-1 Step #Height
          DisplaySprite(k, x, y)
          DisplaySprite(k%#NbSprite, x, y)
          k+1
        Next
      Next
      tps = GetTickCount_() - tps
  
      If  StartDrawing( ScreenOutput() )
        Locate( 0, 0)
        DrawText( "TPS:"+Str(tps) )
        StopDrawing()
      EndIf 
      FlipBuffers()
      Delay(100)
    Until WindowEvent() = #PB_Event_CloseWindow
  EndIf