gpt4 book ai didi

php - PHP 操作码缓存是否与 __autoload 一起使用?

转载 作者:IT王子 更新时间:2023-10-29 00:07:53 25 4
gpt4 key购买 nike

抱歉,如果这是基本的,我正在尝试尽可能多地了解 PHP 中的 OO,并且我正在慢慢学习如何使用它(非常有限)。

所以我想知道 __autoload() 是否对 PHP 操作码缓存有任何影响?

最佳答案

操作码缓存与自动加载一起工作(或至少应该工作),但您可能会因此而受到性能影响。

来自 Remember: be nice to byte code caches :

<arnaud_> does autoload have a performance impact when using apc ?
<Rasmus_> it is slow both with and without apc
<Rasmus_> but yes, moreso with apc because anything that is autoloaded is pushed down into the executor
<Rasmus_> so nothing can be cached
<Rasmus_> the script itself is cached of course, but no functions or classes
<Rasmus_> Well, there is no way around that
<Rasmus_> autoload is runtime dependent
<Rasmus_> we have no idea if any autoloaded class should be loaded until the script is executed
<Rasmus_> top-level clean deps would speed things up a lot
<Rasmus_> it's not just autoload
<Rasmus_> it is any sort of class or function declaration that depends on some runtime context
<Rasmus_> if(cond) function foo...
<Rasmus_> if(cond) include file
<Rasmus_> where file has functions and classes
<Rasmus_> or heaven forbid: function foo() { class bar { } }

this mail from Ramus :

To clarify, of course conditionally included files get compiled and cached. The issue is not the included files but the resulting conditionally defined classes and functions needing to be redefined on every request. Whether that is significant or not comes down to the specifics of the situation, but there is no doubt that it is slower. It comes down to a NOP vs. a FETCH_CLASS, for example and the NOP is obviously way faster.

关于php - PHP 操作码缓存是否与 __autoload 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1396501/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com