require_once: 1579 require: 1318 __autoload: 578
The second test shows a similar result:
require_once: 1689 require: 1382 __autoload: 658
Am I missing something here?
11–20 of 38 posts
require_once: 1579 require: 1318 __autoload: 578
The second test shows a similar result:
require_once: 1689 require: 1382 __autoload: 658
Am I missing something here?
Hmm, PHP 5.2+ is still that slow with require_once ? I thought they fixed that. Anyway, just use function_exists instead.
Yup, we're on 5.3. May have something to do with the relative vs. absolute paths (we use relative), but still... Turns out we didn't need require_once anyway, all but a couple of includes in our entire codebase were in that one area.
I'm trying to understand the metrics here. Doesn't the first test show that _autoload is actually much faster than require or require_once? require_once: 1579 require: 1318 __autoload: 578 The second test shows a similar result: require_once: 1689 require: 1382 __autoload: 658 Am I missing something here?
Things in favor of Autoload:
1) Ease-of-use of not worrying about if your class is available
2) If you don't use Autoloading and require clases, you have to load all of those from the opcode cache (and make APC keep track of them) despite that you may not be using many of those classes at all.
3) It helps encourage putting things in classes (whether they are static functions or not).
4) If you ever need to conditionally require a class, you are likely going to run into the same opcode cache hits (instead of NOPs) as Autoload. You'll have to include ALL of your classes to avoid the problem.
Earlier quoted context omitted.
Yup, we're on 5.3. May have something to do with the relative vs. absolute paths (we use relative), but still... Turns out we didn't need require_once anyway, all but a couple of includes in our entire codebase were in that one area.
Out of curiosity, what does your include_path look like? Is ./ the first element, the last, or somewhere in the middle?
Hmm, PHP 5.2+ is still that slow with require_once ? I thought they fixed that. Anyway, just use function_exists instead.
Yup, we're on 5.3. May have something to do with the relative vs. absolute paths (we use relative), but still... Turns out we didn't need require_once anyway, all but a couple of includes in our entire codebase were in that one area.
Every time I see an article like this I thank God I'm not using PHP. It's always, "Remember to always use do_something() instead of dosomething() or else something will suck for some reason."
Every time I see an article like this I thank God I'm not using PHP. It's always, "Remember to always use do_something() instead of dosomething() or else something will suck for some reason."
This article is a serious micro-optimization and, in general, not something people should be that worried about. If you nit-pick enough, all platforms have these sorts of issues.