首页 > Web开发 > 详细

3-7 PHP内置函数之间的性能测试 microtime()测试isset()和array_key_exists执行时间

时间:2017-03-07 08:44:47      阅读:214      评论:0      收藏:0      [点我收藏+]
技术分享
<?php
header(‘Content-Type:text/html;charset=utf8‘);
$_start=current_time();

$array1=range(1000,2000);
$i=0;
while ($i<200000){
    ++$i;
    // isset($array1[$i]); 55ms
    array_key_exists($i,$array1);// 80-90ms
}
$_end=current_time();
function current_time(){
    list($usec,$sec)=explode(‘ ‘,microtime());
    return ((float)$usec+(float)$sec);
}
echo ‘执行时间‘.number_format($_end-$_start,3);
View Code

 通过microtime()测试isset()和array_key_exists执行时间

3-7 PHP内置函数之间的性能测试 microtime()测试isset()和array_key_exists执行时间

原文:http://www.cnblogs.com/jiaochengli/p/6512763.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!