您好,欢迎来到码863代码分享网! 请[登录] / [注册]

php各种语句速度测试if语句与调用函数千万次大约0.05

编辑

先说结论复杂点的if判断语句千万次0.35秒,简单的千万次0.06秒  i5-8265u  deepin20.2.4


//千万次0.05秒   加empty is_null


$start=microtime(true);

$i=0;

while($i++<10000000)

if(empty($i)){

}

echo "\n".number_format(microtime(true)-$start,9);


//千万次0.07秒   加empty is_null


$start=microtime(true);

$i=0;

while($i++<10000000)

if($i){

}

echo "\n".number_format(microtime(true)-$start,9);



//千万次0.2秒 

$start=microtime(true);

$i=0;

while($i++<10000000)

if(strpos('asdfsad.dfsdfdfsd','.')){

}

echo "\n".number_format(microtime(true)-$start,9);


//千万次0.05秒 

function get(){

return 'ok';

}

$start=microtime(true);

$i=0;

while($i++<10000000)

get();

echo "\n".number_format(microtime(true)-$start,9);


//万次0.14秒   ssd硬盘

$start=microtime(true);

$i=0;

while($i++<10000)

@file_get_contents('./'.$i.'.txt');

echo "\n".number_format(microtime(true)-$start,9);


CopyRight 2002~2023 精通2100网 联系邮箱:qqtxt@163.com
版权所有:精通2100网 湘ICP备2023018646号-1
MYSQl共执行 3 个查询,用时 0.0015699863433838 秒,PHP脚本用时 0.004456 秒,占用内存 0.502 MB,Gzip 已启用