TImage loop oddity

BlitzMax Forums/BlitzMax Programming/TImage loop oddity

tonyg(Posted 2006) [#1]
Can't work out why there is a difference in time for this code. If I use seperate images in the loop I get the same 'odd' results.
Graphics 640,480
Const numloops=25000
Local image1:TImage=LoadImage("max.png")
t1:Int=MilliSecs()
For Local x:Int = 1 To numloops
	DrawImage image1,0,0
Next
t2:Int=MilliSecs()
For Local y:Int = 1 To numloops
	DrawImage image1,0,0
Next
t3:Int=MilliSecs()
Print (t2-t1) + " " + (t3-t2)

On my system numloops set to 20000 produces same results for both the X and Y loops (27ms).
When I increase to 25000 the X loop returns 34ms while the Y loop returns 180ms and even as much as 1287ms.
I thought it was GC kicking in but manual mode shows similar results.


TartanTangerine (was Indiepath)(Posted 2006) [#2]
Put a Delay(2000) before t1:int


tonyg(Posted 2006) [#3]
Same thing happens. Similar thing happens with OGL driver just not as bad. Must be a 'resource' thing but I can't see why.


Grey Alien(Posted 2006) [#4]
I have noticed before that test apps need a good long delay as Tim says, you can even maybe put a waitkey in and try it? But as you say, same thing happens, but did you try longer? Otherwise I guess you've just drawn *too* much for your setup. Can you compile/zip and let others with different cards try? I have a 9800XT so it's probably the same ish.


tonyg(Posted 2006) [#5]
...second thoughts, the delay *DOES* make a difference. If I put it after t2 variable and create a new start_time for the Y loop the results are good (i.e. X loop always matches Y loop).
So why's that?


Grey Alien(Posted 2006) [#6]
woah that's even weirder.


skidracer(Posted 2006) [#7]
Untested but I would use a GrabPixmap(0,0,1,1) to flush the graphics pipe before each MilliSecs, otherwise it's just a case of every n drawimages the driver pumps through another n commands to the GPU.


tonyg(Posted 2006) [#8]
Yep, the grabpixmap works as well.
I also ran the test in one big loop and noticed the difference at 50000-60000.
Not sure how often I'd be getting up to that number of images (even with particles) but seemed odd.


Grey Alien(Posted 2006) [#9]
So does that just mean it's a directX lag problem again? As GrabPixmap(0,0,1,1) was one of the early fixes for it.