<?php
date_default_timezone_set("UTC");
$init_time = microtime(true);
function bytesToSize($bytes, $precision = 2)
{
if(!$bytes)
$bytes = 1;
$kilobyte = 1024;
$megabyte = $kilobyte * 1024;
$gigabyte = $megabyte * 1024;
$terabyte = $gigabyte * 1024;
if (($bytes >= 0) && ($bytes < $kilobyte)) {
return $bytes . ' B';
} elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
return round($bytes / $kilobyte, $precision) . ' Kb';
} elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
return round($bytes / $megabyte, $precision) . ' Mb';
} elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
return round($bytes / $gigabyte, $precision) . ' Gb';
} elseif ($bytes >= $terabyte) {
return round($bytes / $terabyte, $precision) . ' Tb';
} else {
return $bytes . ' B';
}
}
function SizeFormat($size){
$units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$power = $size > 0 ? floor(log($size, 1024)): 0;
return round($size / pow(1024, $power),2).' '.$units[$power];
}
for($i = 0; $i< 10000; $i++)
{
SizeFormat(4094 *1024*1024);
}
echo abs(round(microtime(true) - $init_time,5));
?>