ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

PHP Iterator is slooow

February 12, 2009 4:21pm

Subscribe [1]
  • #1 / Feb 12, 2009 4:21pm

    m4rw3r

    647 posts

    One thing I discovered when I played around with PHP, making my db abstraction, was that the Iterator interface is slow.
    Not only when using it, but also in general.

    I tested with 10 000 quereies to the db, then iterated them as an array ($query->result()) with a foreach.
    The query objects had “implements Iterator”, and it was slow.
    After I commented the “implements Iterator”, it sped up with about 0.35 sec, more than 10% !!!

    So I’ve realized that the PHP 4 way is in many cases faster than the PHP 5 way (usually the PHP 5 way is including lots of function calls, which is expensive).
    PHP 5 has some (very good) benefits (class abstraction, visibility, singletons, method chaining), but it isn’t so fast when doing some OOP concepts.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases