2

我正在努力寻找有关各种输出的确切含义的任何详细信息/usr/bin/time -v。即我对文件输入/输出的含义感到困惑。

如果有人对“/usr/bin/time”有一些经验,如果您能帮我解决这个问题,我将不胜感激。

4

1 回答 1

1

你的操作系统是什么,是BSD的linux吗?

在实用程序的手册页(第 1 节)中有一些字段描述time,例如在 Linux 中:http: //man7.org/linux/man-pages/man1/time.1.html

但是时间本身使用内核的一些接口来获取信息,可能wait3/ wait4 http://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 在 rusage 中有很多字段,但并非所有字段都被使用:

   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.
于 2016-11-04T22:22:15.873 回答