Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I can pretty quickly monitor the running time of a process with time:

x@y ~ $ time foo

real        0m14.299s
user        0m4.770s
sys         0m0.440s

Is there a way I can get the same data for I/O and CPU usage of an argument, recorded to STDOUT? A simple command or utility like time would be ideal, where I just pass the argument of the thing I want to run:

x@y ~ $ stats foo

wallclock runtime     0m14.299s
I/O reads             290,420 KB
I/O writes            239,429 KB
peak CPU usage        18.62%
mean CPU usage        1.44%
# etc.
share|improve this question

2 Answers 2

up vote 23 down vote accepted

look at the time man page on your system, some implementations have format options to include I/O, CPU and Memory stats (-f).

For instance, GNU time, with -v will show all available info (here on Linux):

/usr/bin/time -v ls

Command being timed: "ls"
User time (seconds): 0.00
System time (seconds): 0.00
Percent of CPU this job got: 0%
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): 3664
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 273
Voluntary context switches: 2
Involuntary context switches: 2
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

On BSDs, use -l instead.

Note that this is the actual /usr/bin/time program, not the keyword that some shells like bash provide which you invoke with time pipeline.

share|improve this answer
zsh's time keyword can also be configured (with $TIMEFMT) to provide with that information. – Stéphane Chazelas Mar 19 '14 at 21:02
This is exactly what I wanted. Perfect! Also, thank you to the editors of this post who clarified that you'll need to run it with command time -v ... since bash is hijacking time. – John Feminella Mar 19 '14 at 23:19

The command strace can be useful, you can limit the trace to only count -c or a subset of system calls,

-e trace=set
      Trace  only  the  specified set of system calls.  The -c option is
      useful for determining which  system  calls  might  be  useful  to
      trace.   For  example,  trace=open,close,read,write  means to only
      trace those four system calls.  Be careful when making  inferences
      about  the  user/kernel  boundary if only a subset of system calls
      are being monitored.  The default is trace=all.

In this answer, I use it to count the number of system calls. I don't know if anything will give you a summary breakdown of throughput, however strace can produce the figures for something like awk to summarise.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.