Motivated

Posted by Misconstruct on Feb. 27, 2011, 5:39 p.m.

After playing around with Polystyrene Man's bloomoon life sim, I had very mixed feelings. One one hand, it's really awesome. On the other, it gets really slow very quickly. It would be awesome if it could handle large populations with less slowdown.

I knew that a speedup might be possible by ditching the Game Maker objects that bloomoon uses in favor of a single object that manipulates data structures. But a desire to actually see what kind of speedup might be possible grew, and so I created a simple prototype.

The prototype contains "plants" and "herbivores" with some simple behavior. I've created two versions, one using one Game Maker object controlling data structures and one using Game Maker objects for everything.

I'll be reporting the FPS and memory usage of each at various object quantities.

500 Plants, 500 Herbivores:

Objects: 45 FPS; 12,080 K

Data Structures: 33 FPS; 11,640 K

1000 Plants, 1000 Herbivores:

Objects: 20 FPS; 13,300 K

Data Structures: 17 FPS; 12,604 K

2500 Plants, 2500 Herbivores:

Objects: 5 FPS; 15,752 K

Data Structures: 7 FPS; 13,932 K

5000 Plants, 5000 Herbivores:

Objects: 2 FPS; 18,748 K

Data Structures: 4 FPS; 14,588 K

10000 Plants:

Objects: 3 FPS; 15,816 K

Data Structures: 3 FPS; 12,020 K

10000 Herbivores:

Objects: 1 FPS; 20,408 K

Data Structures: 4 FPS; 15,280 K

Analyzing this data, one thing is definite. The data structures' memory usage is consistently less than the objects. Not surprising, given how many unnecessary variables the objects have.

Opposite of what I thought would be the case though, the objects are actually faster for the most part. Only when the object count is very high do the data structures start to perform better.

If you want to take a look at 'em, here are the GMKs:

http://www.64digits.com/users/Misconstruct/ds_obj.gmk

http://www.64digits.com/users/Misconstruct/ds_sim.gmk

Comments

Polystyrene Man 13 years, 1 month ago

It will be interesting to see how this changes once we introduce a bunch of variables to each object/"object."

Misconstruct 13 years, 1 month ago

Yeah. The herbivores seem to perform better in the data structure version, and they have twice as many variables as the plants do. Though I'm thinking most of the performance difference comes from the fact that the regular objects use mp_linear_step() whereas I had to write something to take its place for manipulating the data structure.