Performance of Phalcon\Loader vs Zend_Loader

I have a question for the developers of Phalcon, who are familiar with the internal workings of the framework.

I have a ZF1-based project and I decided to substitute ZendLoader with Phalcon\Loader to gain performance. ZendLoader is relying on classmaps to load classes.

To my great surprise, there was almost no difference in performance.

Which I find very hard to believe, knowing how bloated Zend_Loader is (regular expressions and so on).

Can Phalcon\Loader essentially be as slow as Zend_Loader using classmaps?

Thanks, Temuri

Afaik classmap is a bad loading alternative, i think phalcon and Zend do almost the same stuff when loading. Anyway the loader is not a big load factor in an application.

You can maybe try with composer. Look if there is a difference.


classmap is a bad loading alternative ..... >You can maybe try with composer

maybe not so, since from what I can see, composer is doing exactly that - generating classmaps.

i think phalcon and Zend do almost the same stuff when loading

more or less, yeah. Only ZF uses hundreds lines of code to achieve the same.

Anyway the loader is not a big load factor in an application

that depends on amount of classes, really. In my app, sometimes it's generating more load than DB handler.

Thanks, Temuri


I was speaking of Composer, because i think (not sure) that when you use the composer classmap, it will compile all your classname / path when you run composer install/update and no more during the application runtime. Dont know if there would be a difference !

I think that the most expensive part of any class loader is not lookup of the class in the map but require() the file with the class and, if you are not using an opcode cache, its compilation by Zend Engine.



Essentially, you are saying that I shouldn't expect Phalcon\Loader to be faster?

It will be faster but not orders of magnitude. Yes, Phalcon will probably find the file name by the class name faster than Zend but filename lookup is not the bottleneck here. It will take much more time to open the file (I/O operations are costly) and compile it. Both tasks are performed outside of Phalcon\Loader or Zend_Loader. But for the definitive answer you should probably benchmark both cases.

Phalcon need a profiler component. +1