标签:sum pow sage round 方法 public its count bytes
/**
* 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;
}
标签:sum pow sage round 方法 public its count bytes
原文地址:https://www.cnblogs.com/cyq632694540/p/13644317.html