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();
$start_execution_time = microtime(true);
$ending_memory = memory_get_peak_usage();
$end_execution_time = microtime(true);
echo "<br>";
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'>".($end_execution_time - $start_execution_time)." Second</span></b></p>";

Thanks.

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.