Skip to content

Instantly share code, notes, and snippets.

@maynagashev
Created November 25, 2017 20:41
Show Gist options
  • Save maynagashev/988a7e798c945cc38f6456bdd091cf6b to your computer and use it in GitHub Desktop.
Save maynagashev/988a7e798c945cc38f6456bdd091cf6b to your computer and use it in GitHub Desktop.
memory_get_peak_usage tracker function
<?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