Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active March 3, 2024 22:21
Show Gist options
  • Save tkuchiki/4b77005cc64426b28c3d to your computer and use it in GitHub Desktop.
Save tkuchiki/4b77005cc64426b28c3d to your computer and use it in GitHub Desktop.
/usr/bin/time

Usage

http://man7.org/linux/man-pages/man1/time.1.html
http://linuxjm.sourceforge.jp/html/LDP_man-pages/man1/time.1.html

Format

Time

$ /usr/bin/time -f "%E %e %S %U %P" sleep 1.5
0:01.50 1.50 0.00 0.00 0%
%E     Elapsed real time (in [hours:]minutes:seconds).

%e     (Not in tcsh.) 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

$ /usr/bin/time -f "%M %t %K %D %p %X %Z %F %R %W %c %w" sleep 1.5
660 0 0 0 0 0 4096 0 206 0 3 2
%M     Maximum resident set size of the process during its lifetime, in Kbytes.

%t     (Not in tcsh.) 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.) 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.) 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

$ /usr/bin/time -f "[%C] %I %O %r %s %k %x" sleep 1.5
[sleep 1.5] 0 0 0 0 0 0
%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.) Name and command-line arguments of the command being timed.

%x     (Not in tcsh.) Exit status of the command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment