Time

如何確定程序的掛鐘時間?

  • June 17, 2013

我找到了通用的 Linux 程序time,它對命令進行計時。例如,假設我想為foo. 我可以用:

time foo

這給出了這個範例輸出:

real    0m8.738s
user    0m5.796s
sys     0m0.576s

但是,手冊頁time似乎有點不清楚(儘管我是 Linux 新手):

TIME(1)                       Linux User's Manual                      TIME(1)



NAME
       time - time a simple command or give resource usage

SYNOPSIS
       time [options] command [arguments...]

DESCRIPTION
       The  time  command  runs  the  specified program command with the given
       arguments.  When command finishes, time writes a  message  to  standard
       error  giving  timing statistics about this program run.  These statis-
       tics consist of (i) the elapsed real time between invocation and termi-
       nation, (ii) the user CPU time (the sum of the tms_utime and tms_cutime
       values in a struct tms as returned by times(2)), and (iii)  the  system
       CPU  time  (the  sum of the tms_stime and tms_cstime values in a struct
       tms as returned by times(2)).

“真實”時間是指掛鐘時間嗎?

“真實”時間是經過的時間,通常是掛鐘時間之間的差異,但並非總是如此。

例如,如果您在時間更改為 02:00 的語言環境中的夏令時(夏季)時間生效當天的 01:59:00 開始一個過程,並且該過程需要兩分鐘,那麼實際經過的時間為兩分鐘,而掛鐘顯示的時間差為一小時兩分鐘。(當時間偏移變回時,掛鐘差將為負,但實際經過的時間將繼續保持不變。)

引用自:https://unix.stackexchange.com/questions/79703