I got a bunch of comments on my previous post: Empirical Testing of Custom Tag vs. CFC for Output. A few of them stuck with me and so I went and tweaked my trials.
First Ray Camden pointed out that there’s more to consider than just performance when evaluating coding practices. He is completelyright in that point and I completely agree. However I was interested in whether or not there was more than just a stylisticdifference between the methods (output using Custom Tags versus using CFC’s) I was exploring. One of the attributes I was looking at was performance.
But Sean Corfield pointed out that maintainability was the chief attribute that leads him to prefer Custom Tags. Specifically, that CFC’s couldn’t be easily edited by traditional web designers. I buy that. .
Sean then went on to point out that my number didn’t match what he was able to get on his laptop. Under his tests with Trusted Cache turned on, he was able to get Custom Tag performance to match CFC performance. I went back and noticed that my “production” instance didn’t have the Trusted Cache turned on. So I reran the tests with Trusted Cache enabled.
Finally, Mark Fuqua pointed out that I wasn’tusing a realistic output function. Specifically, it just dumped the letter ‘h’. So I created a simple navigation <ul$gt; and the code encapsulator disables the link for the current page. I then added an element of random selection for which navigation choice would be deactivated. (This will make more sense if you look at the code.) .
Results
I had to up the number of iterations to 10000 to tease out a difference. As you can see, the difference is negligible.
Methodology | Average Time (ms) |
---|---|
CFC Invoke from Memory | 306 |
Custom Tag | 391 |
CFC Direct Invoke | 2200 |
So then I tried 10000 iterations with the Trusted Cache Enabled, and presenting a navigation list.
Methodology | Average Time (ms) |
---|---|
CFC Invoke from Memory | 766 |
Custom Tag | 965 |
CFC Direct Invoke | 2611 |
Conclusions: Okay there are still slight performance differences, however to see them you have to iterrate over them 10000. I’m not convinced that they are really significant in that case. So don’t go out and rearchitect just yet. However, now that I have a better understanding of why one would choose Custom Tags over CFC’s I’m sticking with my method.
Source Files: If you would like to reproduce my experiment, please feel free to give it a try, it’s been updated with new code for a the navigation interface: Source Files