Game Timing & Alt-Tab?

BlitzMax Forums/BlitzMax Programming/Game Timing & Alt-Tab?

Well, here's something interesting. On a hunch, I inserted a timer into the JerkTester code posted above. My idea was that the jerkiness was caused by the program competing for resources with the rest of the system, and that we might see better results if the program shared a little better. (I basically inserted the waitTimer line, and also changed the flip 1 to flip 0) The result was that I see many fewer jerks with the modified code. Which is this:

SetGraphicsDriver GLMax2DDriver()
'Graphics 800,600,32
Graphics 800,600,0

Local t1:Int
Local t2:Int
Local test: Int
Local high: Int
Local lo:Int = 200
Const MAXVALUES=800
Local values:Int[MAXVALUES]
Local counter=0
Local loops = 0
Local average = 0
Local total = 0

local timer:tTimer=createTimer(100)

While Not KeyHit(KEY_ESCAPE)
	t1=MilliSecs()
	Cls
	DrawText "Current: "+test,0,0
	DrawText "High:    "+high,0,20
	DrawText "Low:     "+lo,0,40
	DrawText "Average: "+average,0,60
	DrawText "Press <Space> to reset High",0,80
	DrawText "Press <Escape> to exit",0,100
'	DrawText GCMemAlloced(),0,80
	For Local i=0 To MAXVALUES-2
		SetColor 255,255,0
		DrawLine 0,500,800,500
		SetColor 255,255,255
		DrawLine i,500-values[i],(i+1),500-values[i+1]
	Next
    Flip 0
    waitTimer(timer)
	t2 = MilliSecs() 
	test:Int = (t2-t1) 
	If test>high Then high = test
	If test<lo Then lo = test
	If KeyHit(KEY_SPACE) 
		high = 0
		lo = 200
		loops = 0
		average = 0
		total = 0
	End If
	values[counter] = test
	Counter:+1
	If counter>=MAXVALUES Then counter = 0
	loops :+ 1
	total :+ test
	average = total/loops
Wend