I wrote the following myscript.php:
<?php
$count=0;
$start=microtime(true);
while ((microtime(true)-$start)<1) {
usleep(1000);
$count++;
}
echo $count;
?>
Instead of a number close to 1000, when I run php -f myscript.php
on my CentOS 2.6.32 x64 kernel (windows 7 host) I get outputs like 35,43,76,543,44,39,29,38... What can I do?
EDIT: I also tried time_nanosleep(0,1000000)
and C code using usleep()
and clock_gettime()
instead, with the same results.