function _optimizedb_format_size in OptimizeDB 6
Convert bytes to the usual size for people.
Parameters
int $size: Size in bytes.
Return value
string The correct size.
2 calls to _optimizedb_format_size()
- optimizedb_admin in ./
optimizedb.module - Configuring the module.
- _optimizedb_tables_list in ./
optimizedb.module - List and the size of the database tables.
File
- ./
optimizedb.module, line 461 - Database Optimization.
Code
function _optimizedb_format_size($size) {
$metrics[0] = 'Byte';
$metrics[1] = 'KB';
$metrics[2] = 'MB';
$metrics[3] = 'GB';
$metrics[4] = 'TB';
$metric = 0;
while (floor($size / 1024) > 0) {
++$metric;
$size /= 1024;
}
$ret = round($size, 1) . ' ' . (isset($metrics[$metric]) ? $metrics[$metric] : '??');
return $ret;
}