Friday, September 7, 2007

CakePHP & CodeIgniter Benchmark

After reading How fast is your framework I was rather intrigued to compare CakePHP, CodeIgniter (Also added Symfony). As both frameworks are very similar and one of the best comparisons I’ve heard is “Cake is like a strict teacher while CodeIgniter is your favorite sports teacher” but I can’t remember where I found it. For me this sums the two very similar frameworks in that Cake has very strict naming conventions etc while CodeIgniter allows you more leeway. This is a particular advantage if your using databases that you do not control or have permission to modify etc. Anyway back to the subject of this post the bench mark of both these frameworks.

Update (11 Dec 2006):
After some kind pointers in the right direction from Larry E. Masters (aka PhpNut) and Nate from CakePhp.org to help showing me small modification and oversights in my testing procedures, I was happy to correct. (Thanks for the help guys). You will notice on line 07 of the helloworld controller the addition of var $helpers = null; and also some modifications to the app/config/code.php setting the AutoSession value to false greatly improved the performance. After some discussion the results of this quick benchmark aren’t really in a real world environment and shortly a more complete set of benchmarks for a simple app will be added. These results will not only be more useful but also be able to test the more advanced features of each framework. The change to production mode also cleared up the failed requests
System:

  • System: 3.0GHz Intel 512 Ram
  • Os: Ubuntu Edgy
  • Webserver: Apache 2.0
  • PHP 5.16

Framework:

  • CakePHP 1.1.11.4064
  • CodeIgniter 1.5.1
  • Symfony 1.0 beta1

Test:

Each framework is required to have the output “HelloWorld!” produced from a view and a controllers will obviously have to be created. The code I have used is shown below along with the benchmarking results. There are no caching available logging and no databases are connected. I’ve used ApacheBench to test and have also shown the results with the call for 10 concurrent users and testing for 60 secs.
ab -c 10 -t 60 http://framework/helloworld

CakePHP

Controller: helloworld_controller.php

02. class HelloWorldController extends AppController {
03. var $layout = null;
04. var $autoLayout = false;
05. var $uses = array();
06. var $helpers = null;
07. function index()
08. {
09. }
10. }

CodeIgniter

Controller: helloworld.php

02. class Benchmark extends Controller {
03. function Index()
04. {
05. $this->load->view('benchmark_view');
06. }
07. }

Symfony

Controller: action.class.php

02. class mymoduleActions extends sfActions
03. {
04.
05. public function executeIndex()
06. {
07. }
08. }

Also for Symfony the layout.php was modified to contains

< ?php echo $sf_data->getRaw('sf_content') ?>'

as it was adding a large amount of HTML content.The views are identical just containing ‘Hello World!’

Results:

I have moved the results to another page to aid reading because as I add each framework it’s starting to get quite long. For the full results: Web Framework Benchmarking Results
Requests per second for each framework:

CodeIgniter:  58.51
CakePHP: 37.46 29.67
Symfony: 22.78

So the results leave no doubt that CodeIgniter is much faster than CakePHP some concern must be present about CakePHP in that 213 requests failed. Symfony comes last but as it’s still in beta maybe this will improve, when it’s a stable release I will run the benchmark again.

If you would like some other frameworks tested leave a comment and I will try to add them later. I will try to add Djanjo later this week then and RoR.

No comments:

About Me

Ordinary People that spend much time in the box
Powered By Blogger