drkjzk3359 2013-08-19 12:16
浏览 50
已采纳

Php包括性能损失

<?php   
$t1 = microtime(true);

require("File0.inc"); // size: 7.0 kB
include("File1.inc"); // size: 30.8 kB 
include("File2.php"); // size: 99.0 kB 
require('File3.php'); // size: 1.6 kB 

echo "{includes: ".(microtime(true) - $t1)." seconds}";
?>

This out puts between 0.013 seconds to 0.018 seconds.
This is really inefficient for me, my code (after it) runs in about 0.0002 seconds.
How can I minimize the execution time taken on including the files?

  • 写回答

1条回答 默认 最新

  • duanpuchun5275 2013-08-19 12:23
    关注

    Including PHP files takes time, there's no way around it.

    If the loading time really is such a big issue for you, you may have to just put all the code into one big file. But that's a nightmare when it comes to modularization and code quality, of course, so you should really consider getting a faster server instead of doing this.

    Meanwhile, you could try caching your output using memcached or APC to improve loading times.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100