public static function format($bytes, $decimals = 2)
{
$exp = 0;
$value = 0;
$symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$bytes = floatval($bytes);
if ($bytes > 0) {
$exp = floor(log($bytes) / log(1024));
$value = $bytes / pow(1024, floor($exp));
}
if ($symbol[$exp] === 'B') {
$decimals = 0;
}
return number_format($value, $decimals, '.', '') . ' ' . $symbol[$exp];
}
/** * @param int $count * @return array */ public function runTest($count = 1) { gc_collect_cycles(); // Forces collection of any existing garbage cycles $this->_profiler->start(); for ($i = 0; $i < $count; $i++) { // Store the result so it appears in memory profiling $this->_executeTest(); } $this->_profiler->stop(); $time = $this->_profiler->getTime(); $timeOne = $this->_profiler->getTime() / $count; $memory = $this->_profiler->getMemory(); return array('time' => $time, 'time_one' => $timeOne, 'memory' => $memory, 'count' => $count, 'formated' => sprintf("Time: %s/%s; Memory: %s; Count: %s", Timer::formatMS($time), Timer::formatMS($timeOne), FS::format($memory), $count)); }