使用 APC(最新版本/最新)时,自动加载真的会降低性能吗?基准?
我试图为使用 APC 时自动加载会降低性能的问题找到明确的答案,为什么(基准?)
PS 发现了这个 链接使用google/stackoverflow,但我想知道这是否仍然成立? PHP 必须改进才能处理这个问题吗?因为自动加载有点酷!
I am trying to find a definite answer to the question that autoload kills performance when using APC and why(benchmarks?)
P.S. Found this link using google/stackoverflow, but I am wondering if this still holds? PHP must been improved to handle this? Because autoload is kind of cool!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我不认为依赖 __autoload() 是一个好的做法。 PHP 是一种松散类型语言,而不是惰性类型语言。 :)
在这里查看一些性能:
Rasmus对此的回答(您也发现了)是我多年来的指导方针:
Personally, I don't believe relying on __autoload() is good practice. PHP is a loosely typed language, not a lazily typed language. :)
Check out some performance here:
Rasmus's answer on this (which you also found) was my guidline through all this years:
我又进行了一些谷歌搜索,发现了这个有趣的文章总结如下:
每个策略运行了 10 次基准:
结论
每种方法都有其优点。在开发过程中,您不一定希望运行脚本来生成类映射或每次添加新类时都手动更新类映射。也就是说,如果您预计站点会有大量流量,那么在部署期间运行脚本来为您构建类映射是非常容易的,从而让您的应用程序获得一些额外的性能。
I did some more googling and found this interesting article summarized below:
Benchmarks were run 10 times for each strategy:
Conclusion
Each approach has its merits. During development, you don't want to necessarily run a script to generate the class map or manually update the class map every time you add a new class. That said, if you expect a lot of traffic to your site, it's trivially easy to run a script during deployment to build the class map for you, and thus let you eke out a little extra performance from your application.