bash时间与php microtime之间的差异

时间:2018-08-05 17:27:33

标签: php bash time microtime

我正在测试php脚本完成所需的速度:

$start = microtime(true);
...
echo 'Time elapsed in seconds: ' . microtime(true) - $start;

对于一个脚本,我得到:以秒为单位的经过时间:0.00069999694824219 对于另一个脚本,我得到的时间以秒为单位:0.0030720233917236

然后我用bash时间测量了相同的脚本和参数,并得到:

time /usr/local/bin/php /home/.../www/cgi-bin/../turnto-qa.php  DOT-9926
real    0m0.678s
user    0m0.089s
sys     0m0.577s

time /usr/local/bin/php /home/.../www/cgi-bin/.../turnto-reviews.php DOT-9926
real    0m0.375s
user    0m0.093s
sys     0m0.276s

谁能解释为什么这些测试的值如此之大地变化?哪种方法最准确?

谢谢!

0 个答案:

没有答案