ColdFusion Object Creation – More
Posted by Steve Brownlee on February 12, 2009Feb 12
Following up on my original post about ColdFusion performance hits on creating objects – it was suggested that I return an array of typed structures instead of an array of components.
I already had a nice AOP class for each of these scenarios, so all I had to do was add the __type__ column to the array of structures, and I was good. The test results below seem logical… except for the first set of testing 50 rows. Converting the query results into an array of structs using a simple function call to another component was actually SLOWER than using AOP or converting to DTOs.
Besides that anomaly, the performance hit for using ColdSpring AOP proxies and using DTOs is clearly visible as you add more data.






hey steve,
your numbers for converting to an array of structs seem awfully high to me. so I ran a test locally on a 1000-row query with 95 columns, and it creates that 1000-element array of 95-key structs in under 200ms on average.
maybe your querytoArrayOfStruct code needs tuned?
marc
Possibly, marc, but the code is absurdly simple. The times include the query time as well. I didn’t just time the conversion process, but the entire request.
More on that marc… I yanked all the code out of my components so I could run unit tests on the conversion and I’m seeing the times you mentioned.
At 50 rows, the conversion to structs take 63ms and the conversion to DTOs take 437ms.
At 1000 rows, the times are 250ms and 7109ms respectively.
now that’s more like it!