Array for images vers type instances for images. Q

BlitzMax Forums/BlitzMax Beginners Area/Array for images vers type instances for images. Q

Galdy(Posted 2014) [#1]
Is drawing the game from an array[] of images faster than an array of type instances for the images?


Henri(Posted 2014) [#2]
Hello,

you could test yourself which is faster
'Store time
Local start:Int = MilliSecs()

'Your test loop
For Local i:Int = 0 To 100000
	Print "Testing...!"
Next

Local stop:Int = MilliSecs()

'Display elapsed time
Print "Loop took " + (stop-start) + " ms to finish!"

-Henri


ImaginaryHuman(Posted 2014) [#3]
Likely not much different unless there are a very large number of images. The time taken to draw the image itself will be longer than the little overhead from working with an array or type fields or linked list. Ultimately though an array is faster.


Galdy(Posted 2014) [#4]
Well, i'd say probably a max off 90-100 images at a time for my dungeon crawl consisting of walls,floors, ceilings primarily. Not counting any creature animations yet.


Derron(Posted 2014) [#5]
I have my assets stored in a tmap and am able to realtime Assets.GetXYZ("identifier").

So I assume the traversal of 1-200 images in a list is not that performance hungry. Especially if you just do a "for local image:TImage = eachin list".
Another advantage is sorting/comparing. If you have kind of Z-indexes or drawOrders (to avoid clipping) you can sort a list more easily.


bye
Ron