A post over in the cf-talk list mentioned that using CreateObject was a lot slower than native datatypes in Coldfusion, well of course it is I thought, but I wanted to see HOW slow they compare, and what the difference would be between them.

So to this aid I did a script that looped, creating objects and timing it, in steps of 50 up to 2000 objects. The code to measure this is as follows:

__MSP_CODE_BLOCK_1__

I added some timing info after each iteration and was adding the objects (a struct and a simple Person component) to a log file.

So you dont think that the Person component is very heavy, I did the barest component possible, you might even say its Duck-like!

__MSP_CODE_BLOCK_2__

The results for the component are pretty uniform, but what surprised me was how little speed it takes to create structures. Obviously this is the case, since they are basically a HashMap and in ColdFusion a very long running primitive (i.e. been around a while and optimised)

These results of course are of course unfair, you wouldnt create 2000 odd objects, you might create 5-10 of them as services and keep them cached, but what about beans?

Here is the chart of the results: