首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用APC(最新版本/最新版本)时,自动加载真的会降低性能吗?基准?

使用APC(最新版本/最新版本)时,自动加载真的会降低性能吗?基准?
EN

Stack Overflow用户
提问于 2011-01-25 07:35:40
回答 2查看 4.4K关注 0票数 19

我试图找到一个明确的答案,当使用APC时,自动加载会降低性能,为什么(基准测试?)

附注:我在google/stackoverflow上找到了这个link,但是我想知道它是否仍然有效?PHP必须改进才能处理这个问题吗?因为自动加载有点酷!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-01-27 00:50:36

就我个人而言,我不认为依赖__autoload()是一种好的做法。PHP是一种松散类型的语言,而不是懒惰的类型语言。:)

在这里查看一些性能:

Rasmus在这方面的回答(你也发现了)是我多年来的指导方针:

代码语言:javascript
复制
<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 { } }
票数 6
EN

Stack Overflow用户

发布于 2011-01-27 03:16:44

我又做了一些googling,发现下面总结了这个有趣的article

为每个策略运行10次基准测试:

结论

每种方法都有其优点。在开发过程中,您不必每次添加新类时都运行脚本来生成类映射或手动更新类映射。也就是说,如果您希望站点有大量流量,那么在部署期间运行脚本为您构建类映射非常简单,从而让您从应用程序中勉强维持一点额外的性能。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4788452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档