Measure execution times of php scripts

5/5 - (1 vote)

For this we will use microtime() function — Return current Unix timestamp with microseconds.

//Start calculating the time
$time_start = microtime(true);
for($i=0; $i< 1000; $i++){
echo $i." ";
// Finish time calculation
$time_end = microtime(true);
$time = $time_end - $time_start;
// Display script time
echo "</br>The script ran into $time microseconds";

//Result: The script ran into 1.0140018463135 microseconds

Hello there!

I hope you find this post useful!

I'm Mihai, a programmer and online marketing specialist, very passionate about everything that means online marketing, focused on eCommerce.

If you have a collaboration proposal or need helps with your projects feel free to contact me. I will always be glad to help you!

subscribe youtube

Leave a Comment