PHP measure script execution time

You can use this PHP code snippet to measure the execution time of script.


									<?php

$startTime = microtime(true);

//------------Your Code------------
for ($i = 0; $i < 100000; ++$i) {
	echo "Item: " . $i . "<br/>";
}
//---------------------------------

$elapsedTime = microtime(true) - $startTime;
echo "Elapsed Time in microseconds: " . $elapsedTime . "<br/>";
echo "Elapsed Time in milliseconds: " . round($elapsedTime * 1000);

?>
								

ignite.coder

Between two evils, I always pick the one I never tried before.

Comments (0)

No Comments Yet.