= 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)); ?>