string microtime ( void )

  返回格式为“msec sec”的字符串,其中 sec 是当前的 Unix 时间戳,msec 是微秒部分。本函数仅在支持 gettimeofday() 系统调用的操作系统下可用。   字符串的两部分都是以秒为单位返回的。

 

   
   
   
   
  1. function getmicrotime(){ 
  2.     list($usec$sec) = explode(" ",microtime()); 
  3.     return ((float)$usec + (float)$sec); 
  4. $time_start = getmicrotime(); 
  5. for ($i=0; $i < 1000; $i++){ 
  6.     //do nothing, 1000 times 
  7. $time_end = getmicrotime(); 
  8. $time = $time_end - $time_start
  9. echo "Did nothing in $time seconds"
  10. ?>