當前位置: 首頁> 函數類別大全> hrtime

hrtime

獲取系統的高精度時間
名稱:hrtime
分類:雜項
所屬語言:php
一句話介紹:返回系統的高分辨率時間。

定義和用法

hrtime()函數返回系統的高分辨率時間(high resolution time)。

這個時間通常用於性能測量,因為它提供了比常規時間函數(如time())更高的精度。

實例

返回系統的高分辨率時間:

 < html >
< body >
<?php
echo hrtime ( true ) , PHP_EOL ;
print_r ( hrtime ( ) ) ;
?>
</ body >
</ html >

上述代碼的輸出可能會像這樣:

 749040731418900
Array
(
    [ 0 ] => 749040
    [ 1 ] => 731419500
)

文法

hrtime ( return_as_num )
參數 描述
return_as_num

可選。默認是FALSE。

為false 時,返回格式為[seconds, nanoseconds] 整型數組。

為true 時,返回奈秒( int (64 位平台)或float (32 位平台))。

同類函數
  • 延緩執行若干秒和納秒 time_nanosleep

    time_nanosleep

    延緩執行若干秒和納秒
  • 設置客戶端斷開連接時是否中斷腳本的執行 ignore_user_abort

    ignore_user_abort

    設置客戶端斷開連接時是否中斷腳本的執行
  • 檢查某個名稱的常量是否存在 defined

    defined

    檢查某個名稱的常量是否存在
  • 設置進程代碼頁 sapi_windows_cp_set

    sapi_windows_cp_set

    設置進程代碼頁
  • 把字符串作為PHP代碼執行 eval

    eval

    把字符串作為PHP代碼執行
  • 輸出一個消息並且退出當前腳本 exit

    exit

    輸出一個消息並且退出當前腳本
  • 返回常量的值 constant

    constant

    返回常量的值
  • 等同於exit() die

    die

    等同於exit()