php 计算函数执行时间的方法及获得微妙的方法
2024-08-23 04:22:45
// 获得微妙方法
function getMillisecond()
{
list($s1, $s2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}
原理:分别记录函数开始时间和结束时间,然后时间差就是函数执行的时间
<?php
$start_time = microtime(true); for($i=1;$i<=1000;$i++){ echo $i.'<br>';
} $end_time = microtime(true); echo '循环执行时间为:'.($end_time-$start_time).' s';
?>
最新文章
- (四)SQL入门 数据库的操作与事务管理
- python(14)类,方法,对象,实例
- hadoop配置优化
- ios Swift 算法
- K最近邻算法
- linux下使用split 来分割大文件
- 手机摇一摇效果-html5
- The JRE could not be found.Edit the server and change the JRE location.
- javascript必知必会之prototype
- 基于visual Studio2013解决面试题之0707最小元素
- uva11991 Easy Problem from Rujia Liu?
- Tornado 网站demo 二
- Ubuntu 16.04开启SSH服务
- java基础学习周计划之2--面向对象
- jquery快速入门(一)
- CSS盒模型(Box Model)
- 背水一战 Windows 10 (104) - 通知(Toast): 纯文本 toast, 短时 toast, 长时 toast, 图文 toast
- es6 语法 (Decorator)
- strut2 的数据验证
- PPTP 在Centos 7.1 建立方法与失效处理