php查看运行时间、内存消耗
<?php /*计算运行时间*/ class Runtime { var $StartTime = 0; var $StopTime = 0; function get_microtime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } /*格式化当前内存消耗*/ function memory(){ $size = memory_get_usage(); $unit = array("b","kb","mb","gb","tb","pb"); return @round($size/pow(1024,($i=floor(log($size,1024)))),2)." ".$unit[$i]; } } ?>
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: 查看页面执行php占用内存情况
- 下一篇: oracle 内存使用情况