/usr/bin/time 命令 -v 不起作用

/usr/bin/time 命令 -v 不起作用

我知道关于该命令已经提出/回答了很多问题time,但我的问题似乎仍然不起作用。我一直按照每个人的建议进行操作,并使用/usr/bin/time,这似乎有效,但每次我尝试使用/usr/bin/time -v或 时/usr/bin/time -verbose,它都会发出错误消息

/usr/bin/time: illegal option -- v usage: time [-lp] command.

在理想的世界中,我会使用tstime,但这也不像它所说的那样起作用tstime: command not found。我的bash是3.2。我只是真的不确定发生了什么事......

答案1

Mac OS X 不附带 GNU 堆栈。你有“BSD时间” time.c,v 1.9。您可以通过键入以下内容来验证这一点:

strings /usr/bin/time | grep c,v

BSD时间不支持--verbose,但支持/usr/bin/time -lp

$ /usr/bin/time -lp echo hi
hi
real         0.02
user         0.00
sys          0.00
    700416  maximum resident set size
         0  average shared memory size
         0  average unshared data size
         0  average unshared stack size
       174  page reclaims
         6  page faults
         0  swaps
         7  block input operations
         1  block output operations
         0  messages sent
         0  messages received
         0  signals received
         9  voluntary context switches
         1  involuntary context switches
$

time这似乎提供了 GNU提供的大量输出--verbose

ubuntu@sandbox:~$ /usr/bin/time --verbose echo hi
hi
    Command being timed: "echo hi"
    User time (seconds): 0.00
    System time (seconds): 0.00
    Percent of CPU this job got: 66%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 1804
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 78
    Voluntary context switches: 1
    Involuntary context switches: 3
    Swaps: 0
    File system inputs: 0
    File system outputs: 0
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0
ubuntu@sandbox:~$

如果你真的想要--verbose,你可以安装timeGNU自制:

$ brew install gnu-time
==> Downloading https://homebrew.bintray.com/bottles/gnu-time-1.7.yosemite.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring gnu-time-1.7.yosemite.bottle.1.tar.gz

相关内容