Php 回音占用了太多时间
我想提高php脚本的页面生成时间。 但根据php profiler报告,echo语句大约需要0.9秒 我正在CentOS 5.6版最终机器中使用php-5.3 下面是php代码--Php 回音占用了太多时间,php,profiler,Php,Profiler,我想提高php脚本的页面生成时间。 但根据php profiler报告,echo语句大约需要0.9秒 我正在CentOS 5.6版最终机器中使用php-5.3 下面是php代码-- <?php $AllTimerDataValue = ClMiscellaneous::getAllActivityData();//returns an array of size maximum 40 $output = '<input type="hidden" name="acti
<?php
$AllTimerDataValue = ClMiscellaneous::getAllActivityData();//returns an array of size maximum 40
$output = '<input type="hidden" name="actions" value="'.$_REQUEST['actions'].'">';
$output.= '<table id="gradient-style-dup" class="activity_stream_container_tbl" rules="all" align="center">';
$output.= ClMiscellaneous::getHtmlViewOfSingleActivity($AllTimerDataValue);//returns html code based on $AllTimerDataValue
$output.= '</table>';
echo $output; // This is taking around 0.9 sec
?>
对于评测,我使用的是firefox的DBG Bar插件,在服务器端我使用的是php的DBG模块。原因可能是您正在服务器上使用调试器,我确信echo不会花费0.9秒
但是,您可能希望尝试打印而不是回显 输出的strlen大小是多少?试着用注释掉的最后一个字符串运行这个脚本-1秒钟的不同会很明显。我发现很难相信一个简单的回音会花费将近1秒钟的时间。您可以注释掉echo并再次运行基准测试吗?您是否尝试过使用microtime进行基准测试?您是否使用任何输出缓冲?您还希望使用htmlspecialchars作为$\u请求['actions'的输出