string microtime ( void )php
返回格式爲「msec sec」的字符串,其中 sec 是當前的 Unix 時間戳,msec 是微秒部分。本函數僅在支持 gettimeofday() 系統調用的操做系統下可用。 字符串的兩部分都是以秒爲單位返回的。ide
- <?php
- function getmicrotime(){
- list($usec, $sec) = explode(" ",microtime());
- return ((float)$usec + (float)$sec);
- }
- $time_start = getmicrotime();
- for ($i=0; $i < 1000; $i++){
- //do nothing, 1000 times
- }
- $time_end = getmicrotime();
- $time = $time_end - $time_start;
- echo "Did nothing in $time seconds";
- ?>