如何确定进程的挂钟时间?

And*_*rew 3 time

我找到了通用的 Linux 程序time,它是一个命令的时间。例如,假设我想计时foo. 我可以用:

time foo
Run Code Online (Sandbox Code Playgroud)

这给出了这个示例输出:

real    0m8.738s
user    0m5.796s
sys     0m0.576s
Run Code Online (Sandbox Code Playgroud)

但是,手册页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)).
Run Code Online (Sandbox Code Playgroud)

“真实”时间是指挂钟时间吗?

ric*_*ici 8

“实时”时间是经过的时间,通常是挂钟时间之间的差异,但并非总是如此。

例如,如果您在夏令时生效当天的 01:59:00 在时间更改为 02:00 的区域内启动一个进程,该进程需要两分钟,那么实际经过的时间将是两分钟,而挂钟将显示一小时两分钟的差异。(当时间偏移变回时,挂钟差异将为负,但实际经过的时间将继续相同。)

  • 因此,扩展比喻,“真实”时间是“**秒表**”时间。 (2认同)