Time
/usr/bin/time 命令 -v 不工作
我知道關於該命令的許多問題已被詢問/回答
time
,但我的似乎仍然無法正常工作。我一直在按照每個人的建議做,並且 using/usr/bin/time
,這似乎有效,但是每次我嘗試使用/usr/bin/time -v
or/usr/bin/time -verbose
時,它都會吐出一個錯誤說
/usr/bin/time: illegal option -- v usage: time [-lp] command.
在一個理想的世界裡,我會使用
tstime
,但這也不是它所說的那樣tstime: command not found
。我的 bash 是 3.2。我只是真的不知道發生了什麼事……
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 $
這似乎提供了 GNU
time
提供的大量輸出--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:~$
如果你真的想要,你可以用Homebrew
--verbose
安裝 GNU :time
$ 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 🍺 /usr/local/Cellar/gnu-time/1.7: 8 files, 80K $ gtime --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: 16% 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): 2785280 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 6 Minor (reclaiming a frame) page faults: 279 Voluntary context switches: 2 Involuntary context switches: 6 Swaps: 0 File system inputs: 1 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0