Measure how many memory and time to take execution in php

Measure how many memory and time to take execution in php

$starting_memory = memory_get_peak_usage();
$curTime = microtime(true);
$ending_memory = memory_get_peak_usage();
$timeConsumed = round(microtime(true) - $curTime,3)*1000;
echo "<p><b>Start Pick Memory : <span style='color: green'>".round(($ending_memory/1048576), 2)."Mb</span></b></p>";
echo "<p><b>Total Memory Take: <span style='color: green'>".round((($ending_memory-$starting_memory)/1048576), 2)."Mb</span></b></p>";
echo "<p><b>Total Time Escape : <span style='color: green'>".$timeConsumed." milliseconds</span></b></p>";

Thanks.

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.