"RokuJoel" wrote:
@theEndless, I would just note that if you are trying to squeeze the maximum performance from your code, for example in a game, it is best to avoid using Associative Arrays if possible - array access for Associative Arrays is still significantly slower than accessing a linear array, even though we've did some of work to significantly improve AA performance.
- Joel
Thanks for the note, but if accessing an AA is slow enough to make an appreciable difference in framerate, then there are some serious issues there...
Just to be sure, I just did the following test, which gave me the exact opposite results of what you are suggesting:
a = [0, 0]
aa = { x: 0, y: 0 }
timer = CreateObject("roTimespan")
for loop = 1 To 10
timer.Mark()
for i = 1 to 100000
test = a[0]
next
?"A Loop:";timer.TotalMilliseconds()
timer.Mark()
for i = 1 to 100000
test = aa.x
next
?"AA Loop:";timer.TotalMilliseconds()
next
Output:
------ Running ------
A Loop: 179
AA Loop: 75
A Loop: 145
AA Loop: 70
A Loop: 77
AA Loop: 68
A Loop: 78
AA Loop: 73
A Loop: 78
AA Loop: 67
A Loop: 78
AA Loop: 69
A Loop: 78
AA Loop: 67
A Loop: 78
AA Loop: 69
A Loop: 76
AA Loop: 69
A Loop: 77
AA Loop: 70
In every loop, accessing the AA was ~10% faster.
That aside, note also that that's looping over the AA 100,000 times, which is nowhere near what you'd realistically need to do in a single frame of animation. Reduce that to 1000 loops, and the processing time is almost immeasurable.
EDIT: I just ran the same test on the Roku 2 and got slightly different results, but still nothing significant enough to be concerned about it affecting framerate, IMO.
------ Running ------
A Loop: 211
AA Loop: 149
A Loop: 140
AA Loop: 148
A Loop: 150
AA Loop: 149
A Loop: 135
AA Loop: 154
A Loop: 138
AA Loop: 154
A Loop: 138
AA Loop: 151
A Loop: 136
AA Loop: 147
A Loop: 135
AA Loop: 151
A Loop: 139
AA Loop: 147
A Loop: 137
AA Loop: 148
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)