Linux Time Command

在linux机器上,time命令可以记录程序运行时间。

在控制台直接输入 time <command>, 会输出三个值,real, user, sys. 关于这三个值的含义在很多博客中都有说明。

在后台运行time 命令,输出是user, system, elapsed. 单位也和之前的不一样。

GNU VERSION

       Below a description of the GNU 1.7 version of time.  Disregarding the
       name of the utility, GNU makes it output lots of useful information,
       not only about time used, but also on other resources like memory,
       I/O and IPC calls (where available).  The output is formatted using a
       format string that can be specified using the -f option or the TIME
       environment variable.

       The default format string is:

           %Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
           %Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps

       When the -p option is given, the (portable) output format is used:

           real %e
           user %U
           sys %S

   The format string
       The format is interpreted in the usual printf-like way.  Ordinary
       characters are directly copied, tab, newline and backslash are
       escaped using \t, \n and \\, a percent sign is represented by %%, and
       otherwise % indicates a conversion.  The program time will always add
       a trailing newline itself.  The conversions follow.  All of those
       used by tcsh(1) are supported.

       Time

       %E     Elapsed real time (in [hours:]minutes:seconds).

       %e     (Not in tcsh(1).)  Elapsed real time (in seconds).

       %S     Total number of CPU-seconds that the process spent in kernel
              mode.

       %U     Total number of CPU-seconds that the process spent in user
              mode.

       %P     Percentage of the CPU that this job got, computed as (%U + %S)
              / %E.

       Memory

       %M     Maximum resident set size of the process during its lifetime,
              in Kbytes.

       %t     (Not in tcsh(1).)  Average resident set size of the process,
              in Kbytes.

       %K     Average total (data+stack+text) memory use of the process, in
              Kbytes.

       %D     Average size of the process's unshared data area, in Kbytes.

       %p     (Not in tcsh(1).)  Average size of the process's unshared
              stack space, in Kbytes.

       %X     Average size of the process's shared text space, in Kbytes.

       %Z     (Not in tcsh(1).)  System's page size, in bytes.  This is a
              per-system constant, but varies between systems.

       %F     Number of major page faults that occurred while the process
              was running.  These are faults where the page has to be read
              in from disk.

       %R     Number of minor, or recoverable, page faults.  These are
              faults for pages that are not valid but which have not yet
              been claimed by other virtual pages.  Thus the data in the
              page is still valid but the system tables must be updated.

       %W     Number of times the process was swapped out of main memory.

       %c     Number of times the process was context-switched involuntarily
              (because the time slice expired).

       %w     Number of waits: times that the program was context-switched
              voluntarily, for instance while waiting for an I/O operation
              to complete.

       I/O

       %I     Number of filesystem inputs by the process.

       %O     Number of filesystem outputs by the process.

       %r     Number of socket messages received by the process.

       %s     Number of socket messages sent by the process.

       %k     Number of signals delivered to the process.

       %C     (Not in tcsh(1).)  Name and command-line arguments of the com‐
              mand being timed.

       %x     (Not in tcsh(1).)  Exit status of the command.

http://man7.org/linux/man-pages/man1/time.1.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值