MemoryCollector.php
471 Bytes
<?php
/**
* Created by PhpStorm.
* User: Zip
* Date: 15/4/26
* Time: 下午1:46
*/
namespace Hood\Debug\Debugbar;
class MemoryCollector
{
function echo_memory_usage()
{
$memUsage = memory_get_usage(true);
if ($memUsage < 1024)
return $memUsage . " bytes";
elseif ($memUsage < 1048576)
return round($memUsage / 1024, 2) . " KB";
else
return round($memUsage / 1048576, 2) . " MB";
}
}