How to get duration in microseconds

I want to determine how long a certain part of my php script takes, like

$startTime = microtime(true);
//some operations which needs 0.1 to 100 seconds to run
$endTime = microtime(true);

      

How can I get the duration in microseconds as an integer ?

This does not work:

$duration = (int)($endTime - $startTime);

      

+3


source to share


1 answer


If you want microseconds to be integers:



$duration = round(($endTime - $startTime) * 1000000)

      

+4


source







All Articles