Output buffer, anyone??

Alright, now for the last and final debunking of the PHP vs ColdFusion - a test against time" post by our dear PHP apologist friend Mr. Phil Parsons. I'm sure by now he's deliriously happy he bothered to post that article in the first place. One thing you have to say for ColdFusion: the fans are fierce, loyal and knowledgeable. Challenge us only if you have your ducks in a row and your thinking cap on tight. And I'm sure if I try I can mix a few more metaphors before I finally sleep tonight.

Or we could just skip to the code...

So. I started out working with 200,000 characters. I mean, what fun is it if we can't outdo PHP at its own game, eh? I managed to roll 200,000 characters from local variable into a page buffer and into a different variable in .36ms. I have NO freaking clue why this particular test is significant, but apparently it's one of the ways in which PHP is purportedly better than ColdFusion. However, I just realized something:

Mr. Parsons is running a comparable CPU to mine, however he's running it overclocked at more than 1GHz faster than my lowly (and 4-year-old) MacBook Pro. Intel Core2 Duo 2.8 GHz LAPTOP vs AMD Phenom II X2 550 3.10 GHz @ 3.83 GHz DESKTOP. I wonder how my tests would run on a DESKTOP machine running a full GHz faster than my laptop? Especially considering that in general desktops GHz for GHz perform a bit better than laptops anyway?

So I dropped my character count to 140k, just like his and guess what? My poor, humble laptop burdened with running ColdFusion in a J2EE container, PHP5, Apache, Eclipse, FireFox, and about a half-dozen other things (I currently have 24MB of RAM free, yes, 24MB) managed to run his same test in .26ms. That's .06ms slower, on hardware running a full GHz slower. So you tell me which performs better.

Really... next time you decide to take on another platform with trickery and deceit, Mr. Parsons, think twice.

And now, finally, here's the code!

view plain print about
1<cfscript>
2    string = fileRead(expandPath('.') & "/resources/140kchars.txt");
3    its = 10000;
4    times = [];
5    writeOutput("Char count in the string: " & len(string) & "<br />");
6
</cfscript>
7
8<cfloop from="1" to="#its#" index="i">
9    <cfset start = getTickCount()>
10    <cfsavecontent variable="string2"><cfoutput>#string#</cfoutput></cfsavecontent>
11    <cfset end = getTickCount()>
12    <cfset arrayAppend(times,end-start)>
13</cfloop>
14<cfscript>
15    writeOutput("Char count in the new string: " & len(string2) & "<br />");
16    writeOutput("It took an average of " & arrayAvg(times) & " miliseconds to do whatever it was we just did " & its & " times.");
17
</cfscript>

Interestingly, the bigger the value in the its variable (the number of times we repeat the experiment) the FASTER OUR AVERAGE TIME IS. I just find that extremely interesting. God bless HotSpot. :)

Laterz!

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
How about comparing G-Wan web server? It may outperform by a factor of 100x. I'm not promoting G-wan but waiting for it to stable before testing them in pilot run. If CF and PHP language isn't hard to learn so does C script.
# Posted By James | 1/30/11 8:51 AM
"So. I started out working with 200,000 characters. I mean, what fun is it if we can't outdo PHP at its own game, eh?" - Lol, now who is the aficionado!!

I'm glad I wrote the post, I have learnt from it and now I have amended it hopefully others will also. I'm glad you feel so strongly about ColdFusion and yes I agree this test out of the three was somewhat pointless.
# Posted By Phil | 1/30/11 9:06 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner