Re: [Coding Standards] Loading all files at once

From: Date: Tue, 10 Jul 2007 17:35:48 +0000
Subject: Re: [Coding Standards] Loading all files at once
References: 1 2 3 4 5 6 7 8  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47413@lists.php.net to get a copy of this message
Lukas Kahwe Smith wrote:
the point is that its not just about allfiles.php, but that you actually do not want the require_once calls, because they are just useless overhead if you use an allfiles.php
Actually Lukas, that's not entirely correct. While require_once does provide some overhead, it provides less overhead than doing an if(class_exists()) at the top of every file to insure that the required classes were properly loaded. The benchmark, while I'll admit is very naive, proves that require_once was faster than two straight up requires.
./require.ab.apc2
   Requests per second:    1895.45 [#/sec] (mean)
./both.ab.apc2
   Requests per second:    1964.27 [#/sec] (mean)
The benchmark code is online if you're interesting in attempting to duplicate the results:
    http://pear.domain51.com/bench.tar.bz2
As I've said, it's very simplistic, but it shows the raw performance of require vs. require_once. In my opinion, a tool that generates an allfiles based on the require_once's at the top of the file is what is necessary. For ultimate in speed, you'd want to strip those require_onces out in an environment where allfiles is the only thing that's going to be used, but allfiles shouldn't be the default method - it should be a method that someone's requested when they've installed the code (i.e., pyrus install --allfiles-only SomePackage). -Travis

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