Created
June 29, 2023 11:42
-
-
Save mjarkk/d44cf41fac74a6d3ed637ab40968bcb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function max_mem_usage() | |
{ | |
$bytes = memory_get_peak_usage(); | |
$units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'); | |
$mod = 1024; | |
$power = $bytes > 0 ? floor(log($bytes, $mod)) : 0; | |
return sprintf('%01.2f %s', $bytes / pow($mod, $power), $units[$power]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment