views:

162

answers:

3

In my index.php file I always load some classes used later in code. From profiler it states it sometimes can take about 20% of entire code. Is there any impovement that can make this process faster?

I would try to make this list of classes shorter, but app is very big and checking all dependencies will be costly.

A: 

You might want to look at apc php.net/apc

Zoredache
+2  A: 

Op-code caches such as APC and eAccelerator store a compiled version of your scripts in a cache. This dramatically reduces memory usage and loading time for frequently used static scripts.

Eran Galperin
+2  A: 

While using an opcode cache (such as APC) will reduce the impact of loading/parsing/compiling the class, you'll still be loading them all on every page load & doing whatever initialization accompanies a require_once() call. If you were to set up an autoload function then the classes won't be loaded until your code actually needs to use them. There's a little overhead involved in using a class autoloader but it makes the code easier to maintain.

As always, YMMV, so benchmark your application to see if it's worthwhile in your case.

Sean McSomething