/**
* Comment:获取当前php占用的内存大小
*/
public static function showMemory($precision = 2) {
$bytes = memory_get_peak_usage();
$units = array("b", "kb", "mb", "gb", "tb");

$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);

$bytes /= (1 << (10 * $pow));

$consume = round($bytes, $precision) . " " . $units[$pow];
return $consume;
}
posted on 2020-09-10 10:32  cyqAkin  阅读(155)  评论(0编辑  收藏  举报