I am trying to find time required to execute some function using php. I want accuracy of milli or micro seconds but i get difference in seconds.
The code is as follows:
<?php
$time_start = microtime(true);
usleep(2000000);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Did nothing in $time micro seconds
";
?>
The output i get is 2 micro seconds but it should be 2000000 micro seconds according to program.
If i keep usleep(100) it will give me 0 difference.
Please help me with some solution to this.