(no title)
deletes | 12 years ago
The object was a struct with a size of a typical game object( 100B ), then I trashed the memory by doing a lot of malloc/free using the size of the object. The two tests were one with an array of objects( contiguous array ) and the other an array of pointers to objects which were allocated separately. Then I iterated over the object doing some very simple operation( just enough to access it, and identical for each object ) and timed this. And of course I trashed the memory some more for each time.
The time taken ratio is:
array of objects : array of pointers to objects
1 : 1.189
The second test is identical except I made some extra effort to make sure that every object in array of pointers was not adjacent to any previous one in memory:
array of objects : array of pointers to objects
1 : 2.483
The difference got much smaller once the operation on each object became more time consuming.
No comments yet.