PHP vs ColdFusion – a test against time

Posted on January 29, 2011 by Phil   56 comments

This article has been edited based on the feedback given in the comments section by a large number of Coldfusion professionals–mainly on the use of cftimer effecting the results. My original text stays in place with amendments made based on alterations needed to make the tests a fairer and less PHP bias comparison

Where I work we use ColdFusion but for personal projects I always code in PHP, mainly because ColdFusion is pricey (although Railo and BlueDragon are freely available) and I don’t like coding in it. We were talking about performance at work the other week and I boasted that PHP was much faster than ColdFusion without any real evidence to back it up, just stuff I had read about how badly ColdFusion deals with instantiating objects. Might I add, for a scripting language built on Java, a truly OO language, this is totally lame. I thought I would create a few simple tests to show people just how much better PHP is as a language a comparison between the two languages for which the results are outlined in this article.

The test environment

  • OS: Windows 7 x64
  • CPU: AMD Phenom II X2 550 3.10 GHz @ 3.83 GHz
  • MEMORY: 4GB OCZ DDR3
  • ColdFusion: 9 x64 EDIT: with all debugging features disabled
  • PHP: 5.3.0
  • Apache: 2.2.11

Test one: Speed test on looping

This test involves two identical objects that simply calculate and build an array of the prime numbers between 2 and 10,000 using a simple for loop containing another nested for loop. Below is the code for each (unfortunately ColdFusion is so popular that there is no syntax highlighter for it isn’t supported by syntax highlighter so I had to use the java colouring).

The PHP Primes object

class Primes {

    public function __construct () {}

    public function calc_primes ($to) {
        $primes = array(2,3);
        $primes_len = 2;
        for ($i = 5; $i <= $to; ++$i) {
            $is_prime = true;
            for ($j = 0; $j < $primes_len && $is_prime; ++$j) {
                if ($i % $primes[$j] == 0) $is_prime = false;
            }
            if ($is_prime) {
                array_push($primes, $i);
                ++$primes_len;
            }
        }
    }
}

The ColdFusion Primes object

Original code sample available in download

component {

	public function calcPrimes (to) {
	     var primes = [2,3];
	     var primesLen = 2;
	     var isPrime = true;
	     var i = 5;
	     var j = 1;
             for ( ; i <= to; i++) {
                 isPrime = true;
                 for (j = 1; j <= primesLen && isPrime; j++) {
                     if (i % primes[j] == 0) isPrime = false;
                 }
                 if (isPrime) {
                     ArrayAppend(primes, i);
                     ++primesLen;
                 }
             }
	 }
}

Looping test results

I wasn’t sure whether PHP was up to the task on this one as the Java layer below ColdFusion is pretty good with handling large Arrays but PHP came out just on top. Coldfusion came out slightly better off on the re-run tests

PHP: 128ms, 122ms, 126ms 108ms average
ColdFusion: 128ms, 115ms, 135ms 84ms average

One tip to note here for PHP programmers—count() is exponentially slow on large Arrays. Using the below variation on the calc_primes method actually took 283ms to 10,000, 908ms to 20,000, 1818ms to 30,000 and 4522 to 50,000!!! ColdFusion, using arrayLen, managed it in 1929ms to 50,000.

public function calc_primes_count ($to) {
    $primes = array(2,3);
    for ($i = 5; $i <= $to; ++$i) {
        $is_prime = true;
        for ($j = 0; $j < count($primes) && $is_prime; ++$j) {
            if ($i % $primes[$j] == 0) $is_prime = false;
        }
        if ($is_prime) array_push($primes, $i);
    }
}

Test two: Object creation

In this test I created (around the idea of a bee hive) a Colony object to which we add 10,000 Drone objects through running a while loop with the condition as a method call to the Colony to get it’s Drone count. Again code for each below.

The PHP Colony and Drone objects with test loop

class Colony {

    private
        $drones = array(),
        $colony_name,
        $drone_count = 0;

    public function __construct ($cn) {
        $this->colony_name = $cn;
    }

    public function add_drone ($d) {
        array_push($this->drones, $d);
        ++$this->drone_count;
    }

    public function get_drone_count () {
        return $this->drone_count;
    }

}

class Drone {

    private $message;

    public function __construct ($m) {
        $this->message = $m;
    }

    public function get_message () {
        return $this->message;
    }

    public function set_message ($val) {
        $this->message = $val;
    }

}

// Test Object creation with while
    $times = array();
    for ($i = 0; $i < 100; ++$i) {
        $start = microtime(true);
        $colony = new Colony ('PHP Object Colony');
        while ($colony->get_drone_count() < 10000) {
            $colony->add_drone(new Drone ("I am drone " . $colony->get_drone_count()));
        }
        array_push($times, microtime(true) - $start);
    }
    echo '<p>Object creation test took an average time of ' . array_sum($times)/count($times). ' to run over 100 iterations</p>';

The ColdFusion Colony and Drone objects with test while loop

Original code sample available in download

//Colony
component {

	public function init (cn) {
		drones = arrayNew(1);
	    droneCount = 0;
		colonyName = cn;
		return this;
	}

	public function addDrone (drone) {
		arrayAppend(drones, drone);
	}

	public function getDroneCount () {
		return arrayLen(drones);
	}

}

//Drone
cfcomponent {

	public function init (m) {
		message = m;
        return this;
    }

	public function getMessage () {
        return message;
    }

	public function setMessage (m) {
        message = val;
    }

}

// Test Object creation with while
times = [];
	for (i = 0; i < 1; ++i) {
		start = getTickCount();
		colony = new Colony9("ColdFusion object Colony");
	    while (colony.getDroneCount() < 10000)
	        colony.addDrone(new Drone9("I am drone" & colony.getDroneCount()));
	    arrayAppend(times, getTickcount() - start);
	}
    writeOutput("<p>Object creation test took an average time of " & arrayAvg(times) & "ms to run over 100 iterations</p>");

Object creation test results

I had a good idea about how this test would turn out and I wasn’t disappointed. ColdFusion is ridiculously slow at creating objects. PHP could actually create 500,000 objects quicker than ColdFusion could do the 10,000. Shame on you ColdFusion, shame on you.

PHP: 42ms, 42ms, 42ms 50ms average
ColdFusion: 7924ms, 7524ms, 7339ms – Oh Dear!! 844ms, 569ms, 647ms – see comments! 337ms average

Test three: Output buffer speed

For this test I simply took a 140,000 character long string of Lorem Ipsum text and got both PHP and ColdFusion to write it to a variable from the output buffer. Again code for each below but with the string omitted.

The PHP output buffer code

//Test output buffer speed
    $txt = file_get_contents("string.txt");
    $times = array();
    for ($i = 0; $i < 100; ++$i) {
        $start = microtime(true);
        ob_start();
        echo $txt;
        $out = ob_get_clean();
        array_push($times, microtime(true) - $start);
    }
    echo '<p>Output buffer test took an average time of ' . array_sum($times)/count($times). ' to run over 100 iterations</p>';

The ColdFusion output buffer code

Original code sample available in download

<cfset txt = fileRead(expandPath("string.txt"))>
<cfset times = []>
<cfloop from=1 to=100 index="i">
	<cfset start = getTickCount()>
	<cfsavecontent variable="out">
	    <cfoutput>#txt#</cfoutput>
	</cfsavecontent>
	<cfset arrayAppend(times, getTickCount() - start)>
</cfloop>
<p>Output buffer test took an average time of <cfoutput>#arrayAvg(times)#</cfoutput>ms to run over 100 iterations</p>

Output buffer test results

140,000 characters isn’t too massive a string to deal with but PHP still came out way on top by a pretty sizeable margin.

PHP: 0.2ms, 0.1ms, 0.2ms 0.14ms
ColdFusion: 2ms, 2ms, 2ms 1.39ms

Rounding up

So it’s pretty obvious that if you are looking for performance then stay away from ColdFusion, especially if you are planning on building object oriented applications ColdFusion obviously has issues with performance in dealing with objects which should be considered if using the language in applications where the use of coarse and fine grained objects are needed. On top of that, I might add that ColdFusion fails to offer certain object oriented features such as class level methods and attributes which is so I find annoying . If however you have money to burn and want to get an application that talks to If you are building an enterprise level application that, for instance, needs to interact with Microsoft Exchange built in a day then maybe ColdFusion is for you… Maybe?

I’d be interested to see results of these tests on other systems and server configurations so if you have the time download the files and let us now the results in the comments. I will run these tests on my Linux box later and on a Windows Server box in work on Monday and post the results.

Related Posts

No related posts.

56 Responses So Far

  1. Andreas Schuldhaus January 29, 2011 at 10:31 am

    Thank you for summing this up. On a first glance this looks like a well prepared and good documented benchmark, but I regret having to say, that with ColdFusion debugging enabled, this post about the benchmark is nice to read, but of no real value. Enabling debugging on ColdFusion affects performance significantly. It is advised that you do not enable debugging on a production server and the same is true, if you try to compare application servers on a fair basis.

    Re your “pricey” statement above: Meanwhile with Railo (www.getrailo.org) and Open BlueDragon there are two very good Open Source CFML Application Servers.

    Anyway, thank you very much your post and your efforts.

    Andreas

    • Phil January 29, 2011 at 11:33 am

      True, Railo and BlueDragon are free alternatives so yes that does remove the cost.

      I didn’t suggest enabling debugging on production server so I don’t see your point there. Quoting the Adobe livedocs on the CFTimer tag which was used for each benchmark:

      “Use this tag to determine how long it takes for a block of code to execute. This is particularly useful when ColdFusion debugging output indicates excessive execution time, but does not pinpoint the long-running block of code.”

      If using this increases the time a block of code takes to execute then ColdFusion fails in yet another area for me, but I doubt that is the case.

      • Andreas Schuldhaus January 29, 2011 at 12:34 pm

        You can use the cftimer tag without having ColdFusion debugging enabled. Just use type=”comment”, “inline” or “outline”. Its not the cftimer tag that increases the time a block of code takes to execute. But I’m sure there is not a single application server or program out there, that shows its optimum performance, when run in a debugger environment or debug mode.

        Andreas

      • Phil January 29, 2011 at 12:54 pm

        Maybe so, OK I disabled all other options for the debug output and just ran with timer enabled. It was much quicker for the object creation test so I have updated the results. I still think the tests are a fair comparison. I’m not trying to bad mouth ColdFusion, just compare the performance between the two.

        Thanks

        P.S. PHP still won!

      • Andreas Schuldhaus January 29, 2011 at 1:08 pm

        Thanks for updating the results. I have no problem with PHP winning the race in you comparison. It just didn’t feel right for me in your original post ;-) .

        Thanks

        Andreas

  2. Pingback: Tweets that mention PHP vs ColdFusion – a test against time | Phil Parsons -- Topsy.com

  3. Justin Carter January 29, 2011 at 12:50 pm

    Phil, it looks like you’re running your code with request debugging turned on. Debug mode affects performance so you can’t really run benchmarks with it turned on as it will skew your results. The whole point of debugging is that ColdFusion will log extra information about all your code that is being executed so of course it will be inherently slower. If you turn it off the object creation should be much faster – it takes around 560ms on my system with your code.

    The other tests (up to 10,000 primes and the long string) take 95ms and 0ms respectively on my system (a modest Core i5).

    • Phil January 29, 2011 at 1:04 pm

      Thanks Justin, I have also re-run the tests and updated the results. Only real change for me was the object creation which was far quicker than before. Does seem a bit retarded that cftimer is effected by the other settings though.

      • Justin Carter January 30, 2011 at 9:15 am

        No worries ;)

        Also, it’s not really that cftimer itself is affected, it’s the execution of *all* your code that is affected. It’s like compiling a project in Visual Studio in Debug mode rather than Release; the compiler puts a bunch of extra stuff into the compiled code so that you can get extra information about what’s happening in your code, use step debugging, etc. That’s why you can’t performance test or load test something under debug conditions, you’ll get false results :) In this case, it just so happened that you could see the difference when instantiating thousands of objects at a time, compared to the difference with the other tests.

  4. Mike Henke January 29, 2011 at 2:48 pm

    Can you run the same tests on railo?

    Also for ur tests on ACF were you using the built in jrun/web server? You may try to run it on tomcat/apache to be more fair. You maybe be seeing a difference between web and application server differences.

    Thanks

    • Phil January 29, 2011 at 2:54 pm

      Mike, both CF and PHP are running on the same Apache install.

      Unfortunately I don’t have Railo set up so can’t do the comparison between the two. If you have Railo then I’d be interested to see if it is quicker than CF.

  5. Brian Kotek January 29, 2011 at 3:35 pm

    I’m also not sure if you’re just deliberately trying to show the ugliest version of the CF code that you can? Because this:

    arrayAppend(drones, drone);
    ++droneCount;

    Could just be written as:

    public function addDrone( drone )
    {
    arrayAppend( drones, drone );
    ++droneCount;
    }

    • Phil January 29, 2011 at 3:42 pm

      Sure for version 9 but earlier versions of ColdFusion don’t allow script based components and where I work we are still using version 8.

      I didn’t make ColdFusion ugly Brian, but yes it is an ugly language.

  6. Brian Kotek January 29, 2011 at 3:36 pm

    Whoops, make that:

    arrayAppend(drones, drone);
    ++droneCount;

    Could be written as:


    public function addDrone( drone )
    {
    arrayAppend( drones, drone );
    ++droneCount;
    }

  7. Mike Henke January 29, 2011 at 4:13 pm

    Phil, Both on apache for the web server but what is the application server you are using for ACF? I’d guess it is jrun which I have always thought is slow unless optimized.

    Here is the railo download. It should be easy to install and run your tests against. http://www.getrailo.org/index.cfm/download

    To be fair, you should strikeout your comments about “money to burn” and/or specifically say Adobe ColdFusion and mention Railo and OpenBD are free.

    Also for a coldfusion syntax highlighter, it might be your choice of syntax highlighter is lame. I know http://pygments.org/ has CF which is used by github.

    • Phil January 29, 2011 at 4:53 pm

      Mike, yes sorry it is jRun.

      Thanks for the link to pygments, have been looking for a replacement for syntax highlighter for a while as it totally broke in IE9.

      I’ll leave the other remarks though as I was comparing ACF not Railo or BlueDragon.

  8. Aaron West January 29, 2011 at 4:31 pm

    Phil, this is an interesting post; thanks for taking the time to put it together. I enjoyed seeing the comparisons, but there are places where your comparisons could be better / more direct. For instance, to test the output buffer speed you use the cftimer and cfsavecontent tags in ColdFusion. There’s nothing inherently wrong with cftimer, but since you’re testing speed, your code would be better with two GetTickCount() calls for start and end time, and a simple statement. The cfsavecontent stuff is unnecessary if you’re just setting a string.

    All-in-all, comparisons like this are always interesting regardless of what technologies or languages are included. But I’ve never read one that appeared impartial as people tend to write better code in the languages they prefer. Whether that is intentional or not, I don’t know. Cheers.

  9. Mike Brunt January 29, 2011 at 4:47 pm

    Phil, why would you make the statement “but yes it is an ugly language” that pretty much casts doubt on your impartiality here. All programming languages could be called “ugly” in some of their constructs and to me this shows that all you wanted to do with this post, is to find a way to broadcast your own bias. You did that in a manner that appears to be technically objective and that could be misleading. I have spent 11 years on server-side engineering, focussed more on Java and I can state categorically that ColdFusion can be incredibly performant.

    • Phil January 29, 2011 at 5:19 pm

      Thanks Mike, I am slightly biased in my views of ColdFusion I can’t deny that. My response to CF being ugly is to the use of tags in cfcs in versions earlier than 9.

      Perhaps if I were using 9 on a daily basis I’d have a different view.

  10. Brian Kotek January 29, 2011 at 4:48 pm

    Not a valid excuse, Phil. It’s disingenuous to not show the most optimal version of the code.

    Now you just need to show the CF and PHP versions of generating graphs, PDFs, full-text indexing, and pulling a user’s Exchange calendar. Or really, any of the huge number of things that CF can do in one line of code.

    CF might actually be slower than PHP when executing certain code. But Adobe’s focus with CF is not on pure speed. No one is ever going to notice the difference between .2 ms and 2 ms. VERY few people are generating 140,000 character strings or need to generate 10,000 object instances in a single request.

    Adobe’s focus is on making DEVELOPMENT faster. So instead of trying to wring some extra ms out of object instantiation, they added the ability to read and write binary Excel files and other Office types, interact with Exchange and Sharepoint, generate JSON, SOAP, XML, and AMF data without changing any code, integrate directly with JSR 168 and JSR 286 portlet engines, and a lot more. And that’s all stuff that is exponentially more difficult and time consuming to do in PHP.

    In short, while PHP may execute code in a shorter time, CF allows developers to build entire applications in a shorter time. Which adds up to a huge ROI when it shaves weeks or months off the development time of a large application.

    • Phil January 29, 2011 at 5:10 pm

      Brian, I think you missed the point of my article. I wrote about code performance not feature and agree with the points you make about productivity. There are of course libraries to deal with all of that stuff in PHP too though you know, and people share it with each other for the good of the community, not for the good of Adobe.

      • Brian Kotek January 29, 2011 at 5:46 pm

        I got the point of your article just fine, Phil. I’m glad that you acknowledge the productivity benefits of CF over PHP, since a comparison of platforms is about far more than raw speed. In fact, raw speed is generally the LEAST important aspect, by a huge margin. That’s just simple economics: it’s far cheaper to scale up by adding hardware than it is to pay developers to shave milliseconds off the execution time.

        On your community comment, I’m not sure how familiar you are with the CF community, but it is a very active and helpful group. There are numerous resources where people share code and ideas, and while Adobe benefits indirectly from this, that is only a secondary consequence. No one is releasing OSS on RIAForge with the intention of benefiting Adobe. They do it to benefit the community. Just like anyone releasing OSS for any platform.

      • Phil January 29, 2011 at 6:05 pm

        yeah I follow the CF community to some respect though most of my time lately has been focused on node.js and html5.

        Perhaps my response was a bit flippant, I didn’t mean to suggest that CF devs (I’m one of those too after all) would share code to benefit Adobe.

  11. Dave Watts January 29, 2011 at 5:20 pm

    The problem with tests like these is that what they test is artificial. Web application performance testing needs to be parallel, not serial. Unless you have a single script creating thousands of objects, testing the performance of a single script creating thousands of objects tells you … how well a single script can create thousands of objects. It doesn’t tell you how well object creation actually works in an application.

    You want to compare two things? Coding technique X vs coding technique Y, language X vs language Y, etc – it doesn’t matter. To get useful, meaningful values, you need to test real uses in parallel. This means using load testing tools, not writing a single script and running it.

    So, if you want a meaningful test, take your CF application and rewrite it in PHP or vice-versa, then load test both of them. I’ve done load testing for many years, and in many, many cases, performance problems don’t show up when you simply run one script – that script might run very well when run serially, but not in parallel.

  12. Dave Ferguson January 29, 2011 at 5:27 pm

    Phil, You bring up some interesting points here. However, I don’t put much weight into tests like these. This type of test is usually done to prove someones point. They are rarely objective and don’t even test real work scenarios.

    I have to question the validity of what you are stating. As others have posted, there are better and more efficient ways to write the sample ColdFusion code.

    You stated that you believed that PHP was faster and I think you set out to prove that. Also, when you make a comment like this: “I didn’t make ColdFusion ugly Brian, but yes it is an ugly language.” it is hard not see the bias.

    –Dave

    • Phil January 29, 2011 at 5:40 pm

      @both Daves,

      agree with you both, this article is just a bit of fun in essence. I don’t expect anyone to choose either language based on pointless tests, heck given the choice I wouldn’t choose either of these languages but probably go with Ruby or Python.

  13. Jason Dean January 29, 2011 at 6:27 pm

    You said

    “I don’t expect anyone to choose either language based on pointless tests”

    but then in your post you made such ignorant and invalid claims like

    “So it’s pretty obvious that if you are looking for performance then stay away from ColdFusion, especially if you are planning on building object oriented applications. ”

    You have more than a little bias against ColdFusion, and you went into your experiment with a preconceived notion and a predetermined result. Your goal was to prove PHP was faster, that is an unscientific hypothesis and makes your results invalid.

    Hell, for all we know, you cooked the books to prove your invalid hypothesis.

    A valid experiment would have an unbiased hypothesis and would have involved research on how to write a performant ColdFusion application. You clearly don’t know anything about ColdFusion performance.

    Your tests are invalid, and the unfortunate part is, unlike a good scientist, you are too proud (or lazy) to correct them, so the unfortunate reader who puts stock in your post without reading the correcting comments will be left with the mistake impression that they cannot write performant applications in ColdFusion.

    Your hypothesis is flawed, your methods are flawed, your results are flawed, and your resulting theory is flawed. Some of the worst “testing” I have every seen.

    • Phil January 29, 2011 at 7:35 pm

      Sorry Jason but ColdFusion is slow at instantiating objects, end of. It wasn’t ignorant of me to say that, the company I work for develops such systems as stakeholder relationship management platforms where we have to constantly make decisions NOT to use OO features of Coldfusion based on it’s poor performance. Would you be happy creating 1000+ complex objects from a search routine in CF, I wouldn’t but I would in Java, PHP or Python.

      I didn’t “cook the books” download the code and run it for yourself if you don’t trust me.

      Why should I write research on how to write performant ColdFusion applications, I set out to prove PHP was faster, stated that and that was the theme of this article. Sorry if that offends you.

      Why are the tests/results invalid, I corrected them based on information Andreas pointed me to. Nobody should trust one source of information, especially on the web.

  14. Grant Shepert January 29, 2011 at 6:58 pm

    As a matter of interest, I ran your object creation test on my lowly little 2-year old MacBook Pro with Apache/Railo, and the times were: 178ms, 184ms, 222ms. It seems these gaps of yours are become incrementally smaller, aren’t they?

    That said, as has been mentioned numerous time in these comments already the value of this is rather dubious. CF developers use these comparisons in Adobe ColdFusion vs Railo shootouts, and even here the results are tainted by bias and rapidly lose value in the real world.

    RAD, coding efficiency, operating costs, support, frameworks, documentation, community, training and resources are just a few of the real world benchmarks. Since both languages have passed (and maintained) critical mass in these areas long ago (using quality as the measure), short of hiring Forrester all you are left with is “he who holds the bias wins” comparisons.

    Since the performance difference is vanishingly small given real world application, the only way to pay respect to a subject like this is to demonstrate I could create quality, real world code faster and more profitably in PHP than I could in CF. I’m very confident that post isn’t going to come any time soon.

    • Phil January 29, 2011 at 7:45 pm

      Thanks for posting the Railo results Grant.

      While I agree with you on the whole, these margins can make a real difference in time critical systems. Also, I don’t know what experience you have with PHP but day to day web applications are just as quick to write with FREE frameworks such as lithium, codeignitor, doctrine, zend, etc.

      • Grant Shepert January 29, 2011 at 9:52 pm

        I’m confused by the capitalization of FREE in your example. In ColdFusion you can choose either the commercially-supported, Enterprise-respected and foundation engine Adobe ColdFusion, or you can choose to use the free, open source Railo or OBD engines. Every application I’ve developed in the last 2 years on Adobe ColdFusion has run unaltered on Railo, so it’s not apples and oranges. I still run my production servers using Adobe, but that’s by choice not requirement.

        As to time-critical applications, proper development would dictate that caching and bean factories be used (both rich and fantastically powerful in ColdFusion and Railo). If your example scenario’s were unavoidable and these microsecond-differences were critical to the application, you’d be better off looking beyond all script-based languages (sacrificing RAD for pure performance). To suggest otherwise is pure sophistry.

        Finally, I don’t think you are being ‘flamed’ by anybody (certainly nothing stronger than you’ve FREELY given back), but rather commentary on the bias and errors in your arguments and methodology. This was to be expected, no?

  15. Scott Stroz January 29, 2011 at 8:16 pm

    ‘…I set out to prove PHP was faster, stated that and that was the theme of this article.’

    That pretty much says it all. You were determined to prove PHP was ‘faster’ and I have to imagine you wrote code to make sure that would be the result.

    You went into this ‘comparison’ knowing how you wanted it to turn out, so from the start, your methods are suspect.

    • Phil January 29, 2011 at 8:45 pm

      A for loop, very basic object creation and outputting a long string, look at the code examples and you’ll see they are as close as could be. The code is there, if you would like to re-write it and run the tests yourself, or others, go ahead and please post the result here.

      I notice the majority of you flaming me are “adobe community professionals”, would you be flaming if I wrote in bias of PHP but CF turned out faster?

      • Daniel Short January 29, 2011 at 10:48 pm

        Of course not, but the PHP people would :) . That’s human nature. The thing to do to keep that from happening is to write without bias :-) . If you’re going to test something, it should be really *tested*.

      • Dave Watts January 30, 2011 at 12:27 am

        I might not have noticed the post, but I’ve criticized lots of “which is faster” tests in the past on the same grounds as this one. So, yes. The problem is that you “wrote in bias of” one vs the other, rather than testing properly and letting the results lead you. If my goal is to build a test that makes one thing look better than another, I can almost certainly do that no matter what the two things are.

        Also, pointing out errors in your testing methodology isn’t “flaming.” Criticism != flaming.

        And you seem to want it both ways. First, you say the test demonstrates how PHP is better. Then, you say that it’s a bit of fun and useless. Next, you say that the margins of difference in your admittedly useless test are in fact significant.

        Now, it may well be the case that, if you built a proper test, PHP might still be faster! That wouldn’t really surprise me that much. Or it might not. We’ll never know from this test. But you know what’s even faster? Assembly. Clearly, that makes it the best choice for web development.

  16. Jared Rypka-Hauer January 29, 2011 at 10:35 pm

    Guilty as charged. We pay attention, we communicate with each other and we know what we’re talking about. So yeah, a bunch of us are ACPs. So what? If PHP had such a thing I’m sure they’d be all over the posts that cut on PHP. And PHP would probably look like a more professional platform as a result.

    When you try to spread lies (or, at best, misleading half-truths), you get called on it. Especially by people who are experts in their field. The misleading who-hah in question here is:

    So it’s pretty obvious that if you are looking for performance then stay away from ColdFusion, especially if you are planning on building object oriented applications. On top of that, I might add that ColdFusion fails to offer certain object oriented features such as class level methods and attributes which is so annoying . If however you have money to burn and want to get an application that talks to Microsoft Exchange built in a day then maybe ColdFusion is for you… Maybe?

    I mean, if you really want a good example of real-world, production-class performance, turn on CF’s component cache and template cache (does PHP have those?) and then pound the PHP code and the CF code with 500 successive hits from 30,000 simultaneous users using some sort of load test tool. Get your average response times that way.

    Then maybe we’ll have something actually interesting to discuss.

  17. Aaron West January 29, 2011 at 10:48 pm

    Phil, my comments weren’t trying to stir up trouble and I was genuinely interested in your post. But you are correct that I’m an Adobe Community Professional so I’m not a big fan of seeing ColdFusion cast in an incorrect light.

    I’d be perfectly okay with your post if you discussed something wrong with ColdFusion and you used the best possible code (speaking specifically about the cftimer, cfsavecontent section) to demonstrate the flaw. I’d take your results from a post like that and put them in front of the Adobe CF team to try and affect positive change. Honestly, I would.

    But it seems like so many people want to start their writing with the conclusion and then work toward it. That might work for a novelist, but not a technical author. I suppose it’s your site/blog and you can do and write what you want. But a blog post like this one isn’t helpful to people who want an honest evaluation of ColdFusion. And I’m afraid that’s how the post comes across (to me at least).

    That’s all I’m after, is to try and encourage people to be more objective in a post that is intimated as such. And if they can’t be objective, then it might be a good idea to simply not write the post or to be clear at the beginning that you aren’t objective. Cheers.

    • Phil January 30, 2011 at 9:16 am

      Thanks Aaron,

      OK here’s the deal, I will take all the comments into consideration and edit the post to remove any unnecessary bias.

      Hopefully with the constructive criticism received from some of you I can make it a pound for pound test between CF9 and PHP 5.3.

  18. Scott Stroz January 29, 2011 at 11:20 pm

    I don’t see anyone ‘flaming’ you. Merely pointing out that your ‘research’ may be flawed.

  19. Jared Rypka-Hauer January 30, 2011 at 3:32 am

    Honestly, Phil, if you’re going to present quibbles as an argument as to why PHP is superior to ColdFusion… here’s a counter-quibble:

    A variation on the Prime Number example.

    And before you scoff… the results might surprise you.

    Nah, not really. But if you’re really being fair about this you’ll let the comment through anyway.

    • Phil January 30, 2011 at 9:01 am

      Of course I’ll let the comment through, and no the results didn’t surprise me. I actually thought ColdFusion would better PHP on my primes test.

  20. Jared Rypka-Hauer January 30, 2011 at 9:23 am

    Just for the sake of consistency, I’ll post the URLs to my other 2 counter-posts here:

    Object Instantiation

    Output Buffer

    And there’s the full set.

  21. Phil January 30, 2011 at 12:49 pm

    For Mr. Rypka-Hauer, Aaron and all those who contributed in the comments I have amended my original post to try and present a less biased comparison.

    I’ll be the first to admit the areas in which I was wrong and thank all of those who gave constructive criticism.

  22. Steve Bryant January 30, 2011 at 5:10 pm

    Like many others that have commented here, I am a die hard ColdFusion fan. Unlike most comments, however, I have to commend your post.

    You have a bias, but you stated it openly. Most of us are biased in some way. I would rather read something where the bias is known than have someone hide their bias in an attempt to seem fair. Your approach allows the reader to better decide how much weight to give to your tests.

    You have responded well to the criticism that has been levied (fairly, I think) against your test and updated your results accordingly. Moreover, I like that you allow others to download and run your tests.

    Even if your original results had withstood criticism, that wouldn’t have greatly concerned me – for mostly the reasons Dave Watts gave about the lack of significance of these kinds of performance tests (though, I think many of us would prefer if ColdFusion were faster at object instantiation).

    In any event, it was a fun experiment to see and I am glad that you were open about your bias and responsive to criticism.

    • Phil January 30, 2011 at 10:24 pm

      Thanks Steve,

      it’s been a good learning experience that has opened my eyes to areas that I really should invest some research time, mainly features of version 9 and perhaps looking into Tomcat.

      I still prefer PHP, but maybe this is due to the freedom I have had with it that I haven’t had with ColdFusion. The company I work for is possibly looking to move away from ColdFusion, perhaps to Python which I would be happy with, so we are in a kind of limbo on CF8. Perhaps with Railo we could utilise some of the new features without risking the expense of upgrading.

      • Justin Carter January 30, 2011 at 10:44 pm

        +1 to Steve’s comment too.

        Lots of people would have ignored the criticism and stuck with their original findings, so bravo Phil for digging a bit deeper and publishing the results. A fair article always reads a bit nicer than a biased one too ;)

      • Steve Bryant January 31, 2011 at 6:10 pm

        Phil,

        I don’t know anything about your company, but I generally recommend against changing programming languages unless you are 100% sure that you will have to do a complete rewrite anyway.

        The cost of a rewrite is typically so high that you can usually overcome your problems with any modern language without resorting to such drastic measures.

        You have now gotten the attention of several talented ColdFusion programmers who might be willing to help you guys deal with any CF problems you might be having. I know I would.

        I tell this to companies who ask me to reprogram stuff from other languages to ColdFusion as well (though, of course, I tell them that I think ColdFusion is the best choice if they are going to do a rewrite anyway).

      • Phil January 31, 2011 at 8:10 pm

        Thanks for the offer Steve, I don’t believe we have any major problems as such with ColdFusion more that the people I work with have better experience with other open source platforms such as Python.

        It would be a massive commitment to make and one my managers and the company directors would most definitely not take lightly.

        Personally I’d be very happy to work with Python as it is much closer to C which I have strong interest in but if we stay with ColdFusion I’d be willing to involve myself with that much more than I do now.

        One thing to mention is that ColdFusion doesn’t have as big a community around it in England, from what I know, and finding ColdFusion developers is no doubt much harder than finding PHP ones. When I joined the company I had no experience with ColdFusion, only PHP.

  23. Andy K January 30, 2011 at 6:56 pm

    +1 Steve Bryant.

    I think a friendly coding contest would be kind of interesting! Come up with a dozen mutually agreed upon common real world scenarios and allow for the differing communities to offer their best/cleanest/performant/etc. code and see how they compare in a vacuum and under load.

    If nothing else, it would educational for all to see how other people/languages/communities come up with different methods to achieve the same end result.

    • Steve Bryant January 31, 2011 at 6:15 pm

      Andy K,

      I have thought about this from time to time. I think weighting different parameters would be significant.

      For example, I think performance should be given relatively low weight. In fact, I think it should be pass/fail. So long as an application is able to achieve the desired performance at the desired load then it is fast enough.

      Clean code is, of course, a bit of a matter of opinion.

      The real test would be to give a team a set of requirements and measure man-hours to completion. Follow that up with another set of requirements and repeat. Follow that up with giving *another* team the same app with new requirements.

      It would have to be done in person, however, as otherwise it would be too easy to fudge the man-hours.

      Interesting, but – I suspect – not worth the trouble. I would love the challenge though! I think ColdFusion would rock that kind of contest!

  24. Shazzad Hoshien February 9, 2011 at 1:33 am

    owo!! Awesome helpful & fantastic article. Thanks for sharing…..:)

  25. Pal June 15, 2011 at 8:03 pm

    I have programmed in both and I can find examples in each direction whereby I can make create an example where one is faster than the other. If you only need as a development language is to parse large strings and arrays then PHP wins. If on the other hand you need to perform filtering against a live dataset CF would make PHP look like it is standing still. Useless comparisons in most cases unless you need those things specifically.

    For me the elegance of CFML and the CF platform are worth it to me to have. I still get paid to program in PHP but I will not use PHP on my personal projects as I prefer to have more time for fun and family rather than love of coding. That’s again just an opinion.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recommended reading

  • Ben Nadel Articles on “obsessively thorough web development” with Coldfusion and jQuery
  • Christian Heimann's blog – Wait till I come!! Articles on web development
  • David Walsh Articles around PHP, CSS, MooTools, jQuery and just about everything else
  • John Resig Javascript programmer and the creator of the jQuery library
  • Mary Lou (Codrops) Stunning designs with lots of cool jQuery effects

Photostream

  • Loading photostream from Flickr...