Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Memory Usage and Speed vs Code Igniter
  • I know you probably don't want to be constantly associated with Code Igniter, but i'm afraid my first question is going to have to be a comparison of the two. Has anyone rebuilt a Code Igniter project using Fuel PHP and still has them both working so as to compare the speed and memory usage of the two (with the same functionality)? I would assume that Fuel PHP should require less memory and hopefully a better speed performance also, using the benefits the come with PHP 5.3. But i'd be very interested in to see any direct comparisons.
  • If memory serves me right it's pretty much the same, but when you try benchmarking the base yourself you should note that there are differences with the default time & memory reporting: Time: ours starts in the front controller, while CI's only starts after the Benchmark class was initiated.
    Memory: we use memory_get_peak_usage() which reports the maximum amount of memory allocated to PHP during execution and we subtract the initial system overhead memory gotten by memory_get_usage() in the front controller before anything is executed. CI only reports memory_get_usage() at the end which tells you how much is allocated at the end of execution. Also a direct comparisson feature wise is impossible: we have Hmvc build in, modular seperation build in, and a lot of other stuff CI doesn't do out of the box. And last but not least, as many wise have said before me: "Hello world" benchmarking tells you nothing usefull when their performance is comparible. What really would do some good benchmarking is if you use both frameworks to reach the same goal, and check if they're comparible in speed & memory usage then.
  • I'm busy converting ExiteCMS from CI to Fuel, and posted some figures some time ago comparing a finished part (same functionality). Altough I can't remember the exact figures, I know the result was quite dramatic. At that time I still used AR. I'm now converting the code to use the ORM, and I expect a small impact from that. But still, I think improvement is significant. disclaimer: it all depends on your app structure and the way you've coded. I can make "hello world" run out of memory... ;)
  • Jelmer Schreuder wrote on Monday 11th of April 2011:
    If memory serves me right it's pretty much the same, but when you try benchmarking the base yourself you should note that there are differences with the default time & memory reporting: Time: ours starts in the front controller, while CI's only starts after the Benchmark class was initiated.
    Memory: we use memory_get_peak_usage() which reports the maximum amount of memory allocated to PHP during execution and we subtract the initial system overhead memory gotten by memory_get_usage() in the front controller before anything is executed. CI only reports memory_get_usage() at the end which tells you how much is allocated at the end of execution. Also a direct comparisson feature wise is impossible: we have Hmvc build in, modular seperation build in, and a lot of other stuff CI doesn't do out of the box. And last but not least, as many wise have said before me: "Hello world" benchmarking tells you nothing usefull when their performance is comparible. What really would do some good benchmarking is if you use both frameworks to reach the same goal, and check if they're comparible in speed & memory usage then.
    Hmmm interesting points that I hadn't considered, certainly using memory_get_usage() instead of memory_get_peak_usage() seems like pretty shoddy work in the case of Code Igniter. As for feature comparison, I would assume (being fairly new to Fuel PHP) that those sorts of things would only be initialised when called upon, so if you weren't using them, they wouldn't have much difference? Unless that's not the case.
  • Hmmm interesting points that I hadn't considered, certainly using memory_get_usage() instead of memory_get_peak_usage() seems like pretty shoddy work in the case of Code Igniter.
    It's a PHP5.2 method so don't expect it anytime soon (I believe the current version is compatible with 5.1.x and up).
    As for feature comparison, I would assume (being fairly new to Fuel PHP) that those sorts of things would only be initialised when called upon, so if you weren't using them, they wouldn't have much difference? Unless that's not the case.
    The main difference is that Fuel was designed with those features in mind, they're part of Fuel's architecture. This makes a comparisson a less fair in both directions, we may need a tiny bit more memory/time without using those features (though I don't expect it has any meaningfull impact), but if you wanted those features with CI it would slow down a lot while Fuel stays the same. One of the important differences is that Fuel is quite logical behind the scenes and models what actually happens: A request is made (creates request object), it checks all routes (all of which are objects which return true/false depending on if they match), the request creates a response object and instantiates a controller object to deal with both itself and the response. And in the end a response object is output to the browser. All of this is very OO and for example allows for multiple requests/responses (HMVC), but it can just as well be one.
    Something like wrapping routes in objects may need some negligable amount of extra time/memory but if you ever want advanced routing it is inserted in a snap. The truth about this is that it will need a tiny bit more processing power, but it gives you such an incredible amount of power and flexibility in return that any serious application speeds up more than it will slow down as shown in a "Hello world" app.
  • Jelmer Schreuder, can't agree more.
  • I did some tests regarding this, and CI is all good, but I think Fuel has more potential. Its basic DB class handles much better than CI's AR class memory wise, and possibly CPU. The only time when Fuel uses more memory is with the ORM class, usually with one-to-many and many-to-many relationships and your retrieving all related data. I'm no expert in ORM, I'm pretty new to it, but I feel something somewhere might be taking more memory than it should. If you think of speed of development, Fuel is much faster to use. I really would like to see if anyone does CPU benchmarks on it. Also maybe more caching flexibility.
  • The only time when Fuel uses more memory is with the ORM class, usually with one-to-many and many-to-many relationships and your retrieving all related data. I'm no expert in ORM, I'm pretty new to it, but I feel something somewhere might be taking more memory than it should.
    More memory than...? CI doesn't have an official alternative for an Orm so I'm not sure what you're comparing to and what you consider 'more memory than it should'. Could you give some more details on this? All others who have been working with our Orm have been very enthousiastic about its performance so this is quite new to me.
    Also maybe more caching flexibility
    Again, details? I haven't seen an issue on this in the bugtracker or a topic on these forums so I'm not sure in which way you consider our caching not flexible? We offer 3 different storage drivers (File based, Redis & Memcached) and different ways of storing the data (String, Serialized, JSON). All that along with expiration options and dependencies on other caches. What more do you need?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion