PHP 浮点数 转化 整数方法对比 ceil,floor,round,intval,number_format
2013-07-29 00:31
761 查看
ceil,floor,round,intval,number_format - 执行1000W此效率对比
ceil,floor,intval 相差无几
Header("Content-Type:text/html;charset=utf-8"); ini_set('memory_limit','-1'); set_time_limit(0); $count = 10000000; $num = 73.1221; $q = time(); for($i=0; $i<$count; $i++){ number_format($num, 0); } echo 'number_format耗时:'.( time()-$q ).'<br/>'; $w = time(); for($i=0; $i<$count; $i++){ floor($num); } echo 'floor耗时:'.( time()-$w ).'<br/>'; $e = time(); for($i=0; $i<$count; $i++){ ceil($num); } echo 'ceil耗时:'.( time()-$e ).'<br/>'; $r = time(); for($i=0; $i<$count; $i++){ intval($num); } echo 'intval耗时:'.( time()-$r ).'<br/>'; $t = time(); for($i=0; $i<$count; $i++){ round($num); } echo 'round耗时:'.( time()-$t ).'<br/>'; //输出: number_format耗时:11 floor耗时:3 ceil耗时:3 intval耗时:2 round耗时:5
ceil,floor,intval 相差无几
相关文章推荐
- PHP与JS取整数方法int,ceil,floor,round
- PHP关于数据的舍入关键字归类:round() ceil() floor() number_format()
- PHP取整函数对比详解ceil,floor,round,intval
- Js 和 PHP 中保留小数点后X位数的方法 toFixed、round、number_format、sprintf
- php取整函数ceil,floor,round,intval函数的区别
- php四舍五入函数(floor、ceil、round与intval)
- php中除法取整的方法(round,ceil,floor)
- 【PHP】PHP取整函数:ceil,floor,round,intval区别
- php取整函数ceil,floor,round,intval函数的区别
- [转]PHP取整函数:ceil,floor,round,intval的区别详细解析
- PHP取整函数ceil,floor,round,intval的区别
- php取整函数ceil,floor,round,intval函数的区别
- PHP取整函数ceil,floor,round,intval解析
- php四舍五入函数(floor、ceil、round与intval)
- PHP取整函数:ceil,floor,round,intval的区别详细解析
- PHP floor(),ceil(),round(), intval()的用法
- php取整函数ceil,floor,round,intval函数的区别
- PHP基本功之ceil,floor,round,intval
- PHP与JS---取整数方法int,celi,floor,round
- php取整函数ceil,floor,round,intval函数的区别