简体   繁体   English

如何在PHP中提高'include()s'的性能?

[英]How can I improve the performance of 'include()s' in PHP?

I have a 1.9MB PHP library that I am including at the beginning of my scripts. 我有一个1.9MB的PHP库,我在脚本的开头包含了这个库。 It contains all of my database objects, methods, etc necessary for my website. 它包含我的网站所需的所有数据库对象,方法等。 It takes 0.1s to 0.3s to include it each time. 每次包含它需要0.1s至0.3s。

I use eAccelerator to cache the bytecode of this file. 我使用eAccelerator来缓存这个文件的字节码。 What else can I do to optimize the performance of this 'include'? 我还能做些什么来优化这个'包含'的性能?

Split it into modules and load the chunks only when needed. 将其拆分为模块并仅在需要时加载块。 I think that is the only way to really improve performance, I have been in the same situation and only that solved it. 我认为这是真正提高性能的唯一方法,我一直处于同样的情况,只有这样才能解决它。 It's a lot of code to include, in my mind too much. 在我看来,包含很多代码太多了。 I'll bet you a beer that you do not need all 1.9MB of code in every context. 我敢打赌你啤酒,你不需要在每种情况下都需要1.9MB的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM