时时商务社区
标题:
PHP测试程序运行时间的类
[打印本页]
作者:
xgnic
时间:
2018-2-14 08:31
类很简单,主要是运用了几个函数数组列表函数list(),字符串分割成数组函数explode(),获取时间戳和微秒数microtime(),代码如下:
[U]复制代码[/U] 代码如下:
starTime=$this->getMicTime();
}
public function stop(){//获取结束时间
$this->stopTime=$this->getMicTime();
}
public function spent(){//计算程序持续时间
return round($this->stopTime-$this->starTime)*1000;//获取毫秒数
}
}
//举例
$time=new runTime();
$time->star();
for ($i=1;$istop();
echo $time->spent();
?>
您可能感兴趣的文章:
PHP 将图片按创建时间进行分类存储的实现代码
PHP 一个页面执行时间类代码
php代码运行时间查看类代码分享
PHP性能优化工具篇Benchmark类调试执行时间
php中计算程序运行时间的类代码
php实现的Timer页面运行时间监测类
php实现用于计算执行时间的类实例
PHP时间类完整实例(非常实用)
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2