function _perfmon_format_bytes in Performance monitor 8
Same name and namespace in other branches
- 7 perfmon.inc \_perfmon_format_bytes()
Format bytes.
1 call to _perfmon_format_bytes()
- perfmon_get_mysql_performance_variables in ./
perfmon.module - Describes mysql performance variables.
File
- ./
perfmon.module, line 369 - Stand-alone perfmon test system.
Code
function _perfmon_format_bytes($bytes, $precision = 2) {
$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 /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}