最近常常用一些扩展,适当比较所占内存,还有一些扩展执行时间长,检测一下每步的执行时间,能够加以修正调整一下源码函数
microtime() #返回当前 Unix 时间戳和微秒数。 echo (microtime()); //0.36150580 2141832520
常见用法this
$mtime=explode(' ',microtime()); $startTime=$mtime[1]+$mtime[0];
想获取扩展开始分布运行时间能够写一个方法日志
public static function gettime($starttime) { $endtime = explode(' ',microtime()); $thistime = $endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]); $thistime = round($thistime,3); return $thistime; }
使用断点或者记入日志便可code
memory_get_usage() #返回分配给 PHP 的内存量
memory_get_usage()还能够有个参数,$real_usage,其值为布尔值。默认为 FALSE,表示获得的内存使用量不包括该函数(PHP 内存管理器)占用的内存;当设置为 TRUE 时,获得的内存为不包括该函数(PHP 内存管理器)占用的内存。内存