使用APC(最新版本/最新)时,自动加载是否真的会扼杀性能。基准?
我试图找到一个明确的答案,即自动加载在使用APC时会扼杀性能以及为什么(基准测试?
P.S. 使用google/stackoverflow找到了这个链接,但我想知道这是否仍然有效?PHP必须改进才能处理这个问题?因为自动加载有点酷!
我试图找到一个明确的答案,即自动加载在使用APC时会扼杀性能以及为什么(基准测试?
P.S. 使用google/stackoverflow找到了这个链接,但我想知道这是否仍然有效?PHP必须改进才能处理这个问题?因为自动加载有点酷!
就个人而言,我不认为依赖__autoload()是很好的做法。PHP是一种松散类型的语言,而不是懒惰类型的语言。:)
在这里查看一些性能:
Rasmus对此的回答(你也发现了)是我这些年来的指导线:
<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 { } }