2

I know many questions have been asked/answered about the time command, but mine still seems to be not working. I have been doing like everyone suggests, and using /usr/bin/time, which seems to work, but every time I trying using /usr/bin/time -v or /usr/bin/time -verbose, it spits out an error saying

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

In an ideal world, I would have used tstime, but that's not working either as it says tstime: command not found. My bash is 3.2. I'm just really not sure what's going on...

Jacob
  • 23
  • -v is a GNU extension, do you have a GNU version of time? – Eric Renouf Aug 11 '15 at 16:49
  • What OS are you on? – Drav Sloan Aug 11 '15 at 16:50
  • @EricRenouf When I run gcc --version, I get Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix I thought that I had the GNU version...if not, how would I go about getting it? – Jacob Aug 11 '15 at 17:12
  • @DravSloan OSX Yosemite Version 10.10.4. – Jacob Aug 11 '15 at 17:14
  • @jacob if I run /usr/bin/time --version I get GNU time 1.7 so perhaps you'll have a similar result, if not you likely do not have GNU's version. I don't use OSX myself so don't really know how to get the GNU version, except that people seem to talk about homebrew for such tasks a lot – Eric Renouf Aug 11 '15 at 17:26

1 Answers1

3

Mac OS X doesn't ship with the GNU stack. You have "BSD Time" time.c,v 1.9. You can verify this by typing:

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

BSD time doesn't support --verbose, but it does support /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
$

Which seems to provide a lot of the output that GNU time provides with --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:~$

If you really want --verbose, you can install GNU time with Homebrew:

$ 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
Will
  • 2,754