Testing List Performance

by Jouni Miettunen

Games quite often require list of lists i.e. matrixes to save and manipulate data. There are several ways to implement such and, as a very experienced expert, I always knew exactly which way was the most efficient way.

Oh, I so hate to be wrong! Especially since I was so certain that I was right, just based on my very experienced gut feeling. Who can you trust, if not your guts?

During latest flu season I wasn’t able to do much but think. So I thought about one certain game (link to be added later), which I have never played much, which doesn’t interest me too much, but which has been huge success all over the world. There was sample code which kept crashing and which I couldn’t “read” too well. It got me interested in this test sample.

Last night I was recovered enough to write a small test to compare three different ways to access a single random tile inside a matrix. The result was big surprise to me, since the method I had preferred seems to be the slowest!

T1 is matrix based on dictionary. This is the reason, which got me interested in performance testing. I had never seen anything like that before. It’s true, I’ve never studied python, but will do “some day”…

a[(x,y)] = 1

T2 is the way I used to prefer, one simple list where you access a tile with calculated offset. It does have performance advantages, when you handle tiles in rows – or so I still believe :)

b[x + y*dim_x] = 1

T3 is “normal” matrix, a list of lists. I always thought it would be slow or at least not the fastest.

c[x][y] = 1

For results, please check the “List-of-Lists Test” homepage. In short List of Lists was fastest, but in reality performance difference with small data set was irrelevant. Just use whatever you know best.

Btw one comment about results. I’ve been using N96-1 for few days now. I’ve read a lot of bad reviews, also one reasonable set of reviews, and my own opinion is that current firmware is a bit on the slow side. These results tell something else, it was fastest with large data sets. This is most likely because others used memory cards vs internal harddisk, but I wasn’t interested in such comparison. I just needed to compere three different data management ways within same device.

Enjoy,

–jouni

Related posts:

  1. Adobe CS4 Testing feature When I read on this, I couldn’t think anything other...
  2. Annouce: Milkshake 0.1.0, a To Do list organizer In the last weeks I have been working on a...
  3. Undocumented appuifw.Text() font method parameters PyS60 1.4.4 manual briefly says (page 27) that the “font”...
  4. Timer Sample v1.20 Timers, love to hate. They look like they work –...
  5. Localization sample code One feature, which well-done applications have, is localization. It sets...

Related posts brought to you by Yet Another Related Posts Plugin.