Read the latest web development and design tips at Fred Wu's new blog! :-)
Poke me on GitHub

Kohana vs CodeIgniter: Speed and Memory Usage Performance Benchmark

This is just a quick and dirty test, please take it with a grain of salt.

We all know that CodeIgniter is a very fast framework, but how about Kohana? Kohana is packed with more features, so does that mean it is slower? Let’s find out.

The following benchmarks are done on my local Macbook Pro machine (C2D 2.4GHz + 4GB), Leopard 10.5.2, MAMP without any code optimisers or caches.

Because I don’t have *that* much free time, the tests are very simple. I created a simple database with three tables, and the application is going to insert data into the three tables separately, retrieve them in one single query with query binders (or ‘active record’ classes per CodeIgniter’s term) and then clean up the database tables. I’ve also included use of a text helper method: limit words, which is presented in both Kohana and CodeIgniter. Total number of SQL queries: 2204.

I have benchmarked against three applications: CodeIgniter 1.6.1, Kohana SVN (rev 2328) and Kohana 2.1.1.

First of all, let’s see what the profilers told us:

Execution time
CI 1.6.1: 0.5657s
K SVN: 0.5718s
K 2.1.1: 0.5787s

Memory usage (pre-controller)
CI 1.6.1: 642,136 bytes
K SVN: 1,097,976 bytes
K 2.1.1: 1,076,972 bytes

Memory usage (post-controller)
CI 1.6.1: 2,354,524 bytes
K SVN: 3,062,376 bytes
K 2.1.1: 3,026,884 bytes

As you can see, Kohana consumes a lot more memory than CodeIgniter, but their execution times are on par.

Let’s then remove the database functions and just loop through three paragraphs of Loren Iipsum text with the word limiter for 20,000 times, and use ab to test it for 100 times.

Results the lower the better (total time taken).

CI 1.6.1: 110.236098 seconds
K SVN: 130.211059 seconds
K 2.1.1: 130.662462 seconds

Finally, let’s do a ‘hello world’ with ab -c 10 -t 60 (10 concurrent users for 60 seconds). We assign ‘hello world’ to a view variable and pass it onto a blank view page.

Results the higher the better (requests per second).

CI 1.6.1: 122.18 [#/sec]
K SVN: 113.96 [#/sec]
K 2.1.1: 118.54 [#/sec]

As a comparison (just for fun), here are two results for CakePHP:

First run: 18.66 [#/sec]
Second run: 33.47 [#/sec]

The first run was done in default set up whilst the second one was done by using suggested tweaks. CakePHP is in a different league to CI and Kohana in my opinion. In both CI and Kohana, models are optional, but CakePHP revolves around models.

Once again, these tests are just for fun. :)

  • Digg
  • DZone
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Related posts

Tags: , , ,

Comments Section

16 Responses to “Kohana vs CodeIgniter: Speed and Memory Usage Performance Benchmark”

Sidebar might be covered by comments ... consider it a feature! ;)
  1. 2

    It may be useful to know that one of the main “optimization guys”, who actually made the CI word_limiter() this fast, started working on Kohana a long time ago. If it wasn’t for him, CI’s word_limiter() would be easily 50 times slower.

    http://codeigniter.com/forums/.....30/#300297

  2. 3

    Awesome, thanks for the heads up Geert. :)

  3. 5

    thankyou. it’s always been a long time question to me. which one is faster betweeen Kohana & CI.

  4. 6

    Basing from your benchmark. The significant part is Kohana has a higher memory usage. http://www.lorztech.com

  5. 8

    Thank you for the benchmark.

    What about if you add the latest version of kohana (2.3) on to the bechmark ? may be we can find out if there’s significant performance compared to the previous version.

  6. 9

    Hi there, I was looking around for a while searching for unix test and I happened upon this site and your post regarding vs CodeIgniter: Speed and Memory Usage Performance Benchmark | Beyond Coding, I will definitely this to my unix test bookmarks!

  7. 10

    I understand that this tests are just for fun, but I wonder how many “Hello World” websites did you saw on the Internet? In my opinion first test is fine, but “hello worlds” are pretty much useless.

    Also, when it comes to CI and Kohana, there is actually only one choice – obviously Kohana, despite it lacks documentation, tutorials and examples. CI guys decided to stay PHP4 compatible which is DEAD.

  8. 12

    once I got few modules working in CI the memory consumed much more than Kohana

  9. 14

    I did some comprehensive performance benchmarks of all the latest PHP MVC Frameworks including Yii 1.1.1, Kohana 2.3.4 and Code Igniter 1.7.2 as well as others. The results and analysis of results is here: Comparing PHP MVC Framework Performance

Leave a Reply

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