时间:2021-07-01 10:21:17 帮助过:15人阅读
$starttime = getMicrotime();
$str = '';
for($i=0;$i<100000;$i++){
$str .= $i;
}
$endtime = getMicrotime();
printf("run time %f ms\r\n", (float)($endtime-$starttime)*1000);
function getMicrotime(){
list($usec, $sec) = explode(' ', microtime());
return (float)$usec + (float)$sec;
}
$starttime = getMicrotime();
$arr = array();
for($i=0;$i<100000;$i++){
array_push($arr, $i);
}
$endtime = getMicrotime();
printf("run time %f ms\r\n", (float)($endtime-$starttime)*1000);
function getMicrotime(){
list($usec, $sec) = explode(' ', microtime());
return (float)$usec + (float)$sec;
}