Created
November 25, 2017 20:41
-
-
Save maynagashev/988a7e798c945cc38f6456bdd091cf6b to your computer and use it in GitHub Desktop.
memory_get_peak_usage tracker function
This file contains 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 mpu($label = '', $real_usage = false){ | |
//return false; // disable | |
$mpu = round(memory_get_peak_usage($real_usage) / 1024 / 1024, 2); | |
$text = "{$label} {$mpu} MB"; | |
if (function_exists('dump')) | |
dump($text); | |
else | |
echo "<div style='background-color:black; color:white;padding: 1em;'>{$text}</div>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment