xref: /netbsd-src/usr.bin/time/time.1 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.\"	$NetBSD: time.1,v 1.28 2017/07/15 14:40:36 wiz Exp $
2.\"
3.\" Copyright (c) 1980, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)time.1	8.1 (Berkeley) 6/6/93
31.\"
32.Dd July 15, 2017
33.Dt TIME 1
34.Os
35.Sh NAME
36.Nm time
37.Nd time command execution
38.Sh SYNOPSIS
39.Nm
40.Op Fl clp
41.Op Fl f Ar fmt
42.Ar command
43.Op Ar argument ...
44.Sh DESCRIPTION
45The
46.Nm
47utility
48executes and
49times
50.Ar command .
51After the command finishes,
52.Nm
53writes the total elapsed time (wall clock time),
54.Pq Dq real ,
55the CPU time spent executing
56.Ar command
57at user level
58.Pq Dq user ,
59and the CPU time spent executing in the operating system kernel
60.Pq Dq sys ,
61to the standard error stream.
62Times are reported in seconds.
63.Pp
64Available options:
65.Bl -tag -width Ds
66.It Fl c
67Displays information in the format used by default the
68.Nm
69builtin of
70.Xr csh 1
71uses (%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww).
72.It Fl f
73Specify a time format using the
74.Xr csh 1
75.Nm
76builtin syntax.
77The following sequences may be used in the format string:
78.Pp
79.Bl -tag -width 4n -compact
80.It \&%U
81The time the process spent in user mode in cpu seconds.
82.It \&%S
83The time the process spent in kernel mode in cpu seconds.
84.It \&%E
85The elapsed (wall clock) time in seconds.
86.It \&%P
87The CPU percentage computed as (%U + %S) / %E.
88.It \&%W
89Number of times the process was swapped.
90.It \&%X
91The average amount in (shared) text space used in Kbytes.
92.It \&%D
93The average amount in (unshared) data/stack space used in Kbytes.
94.It \&%K
95The total space used (%X + %D) in Kbytes.
96.It \&%M
97The maximum memory the process had in use at any time in Kbytes.
98.It \&%F
99The number of major page faults (page needed to be brought from disk).
100.It \&%R
101The number of minor page faults.
102.It \&%I
103The number of input operations.
104.It \&%O
105The number of output operations.
106.It \&%r
107The number of socket messages received.
108.It \&%s
109The number of socket messages sent.
110.It \&%k
111The number of signals received.
112.It \&%w
113The number of voluntary context switches (waits).
114.It \&%c
115The number of involuntary context switches.
116.El
117.It Fl l
118Lists resource utilization information.
119The contents of the
120.Ar command
121process's
122.Em rusage
123structure are printed; see below.
124.It Fl p
125The output is formatted as specified by
126.St -p1003.2-92 .
127.El
128.Pp
129Some shells, such as
130.Xr csh 1
131and
132.Xr ksh 1 ,
133have their own and syntactically different built-in version of
134.Nm .
135The utility described here
136is available as
137.Pa /usr/bin/time
138to users of these shells.
139.Ss Resource Utilization
140If the
141.Fl l
142option is given, the following resource usage
143information is displayed
144in addition to the timing information:
145.Bl -item -offset indent -compact
146.It
147maximum resident set size
148.It
149average shared memory size
150.It
151average unshared data size
152.It
153average unshared stack size
154.It
155page reclaims
156.It
157page faults
158.It
159swaps
160.It
161block input operations
162.It
163block output operations
164.It
165messages sent
166.It
167messages received
168.It
169signals received
170.It
171voluntary context switches
172.It
173involuntary context switches
174.El
175Resource usage is the total for the execution of
176.Ar command
177and any child processes it spawns, as per
178.Xr wait4 2 .
179.Sh FILES
180.Bl -tag -width Xsys/resource.hX -compact
181.It Aq sys/resource.h
182.El
183.Sh EXIT STATUS
184The
185.Nm
186utility exits with one of the following values:
187.Bl -tag -width indent
188.It 1-125
189An error occurred in the
190.Nm
191utility.
192.It 126
193The
194.Ar command
195was found but could not be invoked.
196.It 127
197The
198.Ar command
199could not be found.
200.El
201.Pp
202Otherwise, the exit status of
203.Nm
204will be that of
205.Ar command .
206.Sh SEE ALSO
207.Xr csh 1 ,
208.Xr ksh 1 ,
209.Xr clock_gettime 2 ,
210.Xr getrusage 2 ,
211.Xr wait4 2
212.Sh STANDARDS
213The
214.Nm
215utility conforms to
216.St -p1003.2-92 .
217.Sh BUGS
218The granularity of seconds on microprocessors is crude and
219can result in times being reported for CPU usage which are too large by
220a second.
221