<?php
/**
*
* @copyright 2012
* echo性能测试
*/
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$start=microtime_float();
for($i=0;$i<1000;$i++)
{
echo 'hello'.$i.'world'.'<br>';
}
$end=microtime_float();
$totla=$end-$start;
echo $totla;
echo '<br>';
$start=microtime_float();
for($i=0;$i<1000;$i++)
{
echo 'hello',$i,'world','<br>';
}
$end=microtime_float();
$totla=$end-$start;
echo $totla;
/**
*
* @copyright 2012
* echo性能测试
*/
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$start=microtime_float();
for($i=0;$i<1000;$i++)
{
echo 'hello'.$i.'world'.'<br>';
}
$end=microtime_float();
$totla=$end-$start;
echo $totla;
echo '<br>';
$start=microtime_float();
for($i=0;$i<1000;$i++)
{
echo 'hello',$i,'world','<br>';
}
$end=microtime_float();
$totla=$end-$start;
echo $totla;
?>
通过多次实验,使用逗号要比连接符快三分之一