【发布时间】:2016-10-13 18:48:11
【问题描述】:
我正在努力寻找有关/usr/bin/time -v 的各种输出的确切含义的任何详细信息。即我对文件输入/输出的含义感到困惑。
如果有人对“/usr/bin/time”有一些经验,如果您能帮我解决这个问题,我将不胜感激。
【问题讨论】:
标签: unix time command-line profiling getrusage
我正在努力寻找有关/usr/bin/time -v 的各种输出的确切含义的任何详细信息。即我对文件输入/输出的含义感到困惑。
如果有人对“/usr/bin/time”有一些经验,如果您能帮我解决这个问题,我将不胜感激。
【问题讨论】:
标签: unix time command-line profiling getrusage
你的操作系统是什么,是BSD的linux吗?
time 实用程序(第 1 节)的手册页中有一些字段描述,例如在 Linux 中:http://man7.org/linux/man-pages/man1/time.1.html
但是时间本身使用一些内核接口来获取信息,可能是wait3/wait4http://man7.org/linux/man-pages/man2/wait3.2.html
在time -v 中打印的数据来自struct rusage,在getrusage(2) 手册页中有描述:Linux http://man7.org/linux/man-pages/man2/getrusage.2.html
Linux 有很多字段在使用,但并非所有字段都被使用:
The resource usages are returned in the structure pointed to by
usage, which has the following form:
struct rusage {
struct timeval ru_utime; /* user CPU time used */
struct timeval ru_stime; /* system CPU time used */
long ru_maxrss; /* maximum resident set size */
long ru_ixrss; /* integral shared memory size */
long ru_idrss; /* integral unshared data size */
long ru_isrss; /* integral unshared stack size */
long ru_minflt; /* page reclaims (soft page faults) */
long ru_majflt; /* page faults (hard page faults) */
long ru_nswap; /* swaps */
long ru_inblock; /* block input operations */
long ru_oublock; /* block output operations */
long ru_msgsnd; /* IPC messages sent */
long ru_msgrcv; /* IPC messages received */
long ru_nsignals; /* signals received */
long ru_nvcsw; /* voluntary context switches */
long ru_nivcsw; /* involuntary context switches */
};
http://man7.org/linux/man-pages/man2/getrusage.2.html 还给出了一些描述并标记了未维护的字段:
ru_utime
ru_stime
ru_maxrss (since Linux 2.6.32)
ru_ixrss (unmaintained)
ru_idrss (unmaintained)
ru_isrss (unmaintained)
ru_minflt
ru_majflt
ru_nswap (unmaintained)
ru_inblock (since Linux 2.6.22)
The number of times the filesystem had to perform input.
ru_oublock (since Linux 2.6.22)
The number of times the filesystem had to perform output.
ru_msgsnd (unmaintained)
ru_msgrcv (unmaintained)
ru_nsignals (unmaintained)
ru_nvcsw (since Linux 2.6)
ru_nivcsw (since Linux 2.6)
POSIX 2004 没有要实现的确切列表,因此它是特定于实现的http://pubs.opengroup.org/onlinepubs/009695399/functions/getrusage.html
标头应定义至少包含以下成员的 rusage 结构:
struct timeval ru_utime User time used. struct timeval ru_stime System time used.
【讨论】: