Re: [Coding Standards] Loading all files at once

From: Date: Thu, 12 Jul 2007 16:28:47 +0000
Subject: Re: [Coding Standards] Loading all files at once
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47437@lists.php.net to get a copy of this message
Paul M Jones wrote:
Which begins to make an argument for having a standard PEAR_Loader class.
For what its worth, I coded a throw-away loader last night to see how well it did. In the simple base case (loading one package that in turn loads two more files using the loader), it was slower by more than 33% to use a loader versus two straight require_once calls with APC on. I modeled the loader after Solar::loadClass() in that it looked for full paths, the only difference being that it kept an array of loaded classes instead of doing a class_exists() on every call. I also tried loading an array of class to file mappings from memcache so it didn't have to iterate across the include_path looking for a file. In a simple case that was actually worse because of the increased overhead of starting memcache. The only way a loader will satisfactorily perform compared to require/require_once is if an extension is build that handles the loading via compiled code. Given the one file - one class paradigm that PEAR uses, a load_class() function "should" (I use that very carefully) be able to outperform require_once. -Travis

« previous php.pear.dev (#47437) next »