Arrays vs Lists (speedtest)

BlitzMax Forums/BlitzMax Programming/Arrays vs Lists (speedtest)

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

There are some problems with this test. First off, nobody in their right mind is going to resize an array by continually slicing it to be one element larger. In this case, you're doing iterations (50,000) worth of mem copies, each one larger than the last (since the array is now larger.) Secondly, there's no need to clutter up the stack with the local Alength when you can just go

Array= Array[..Len(Array)+1]

Of course - as I said, that test is still flawed because nobody should ever use slicing that much. A more accurate test would - on each iteration - create a new array of some size - say, 500 elements - fill it with data and then slice it ONCE to a larger size, say 2000 elements. Then you can divide the elapsed time by the # of iterations and get the approximate amount of time a single slice (of a known size) took.

Lastly, the test that you have labeled "Creating the array by initializing it's size first" is not timing the creation of the array at all, but is instead timing the amount of time it takes to initialize an already created array of 50,000 elements. This might just be a semantics issue - I'm not sure what you were trying to test here.

I'm not trying to harp on you as I always like to see the pro's and con's to different methods - it's just that inaccurate tests are worse than no tests at all.