xref: /netbsd-src/usr.bin/time/time.1 (revision 93ec1db00ab78132bb92fb60e7234713fe35cf55)
1.\"	$NetBSD: time.1,v 1.30 2021/04/05 23:01:55 pgoyette 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 April 5, 2021
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 clpt
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.It Fl t
128Displays information in the format used by default the
129.Nm
130builtin of
131.Xr tcsh 1
132uses (%Uu %Ss %E %P\\t%X+%Dk %I+%Oio %Fpf+%Ww) with
133three decimal places for time values.
134.El
135.Pp
136Some shells, such as
137.Xr csh 1
138and
139.Xr ksh 1 ,
140have their own and syntactically different built-in version of
141.Nm .
142The utility described here
143is available as
144.Pa /usr/bin/time
145to users of these shells.
146.Ss Resource Utilization
147If the
148.Fl l
149option is given, the following resource usage
150information is displayed
151in addition to the timing information:
152.Bl -item -offset indent -compact
153.It
154maximum resident set size
155.It
156average shared memory size
157.It
158average unshared data size
159.It
160average unshared stack size
161.It
162page reclaims
163.It
164page faults
165.It
166swaps
167.It
168block input operations
169.It
170block output operations
171.It
172messages sent
173.It
174messages received
175.It
176signals received
177.It
178voluntary context switches
179.It
180involuntary context switches
181.El
182Resource usage is the total for the execution of
183.Ar command
184and any child processes it spawns, as per
185.Xr wait4 2 .
186.Sh FILES
187.Bl -tag -width Xsys/resource.hX -compact
188.It Aq sys/resource.h
189.El
190.Sh EXIT STATUS
191The
192.Nm
193utility exits with one of the following values:
194.Bl -tag -width indent
195.It 1-125
196An error occurred in the
197.Nm
198utility.
199.It 126
200The
201.Ar command
202was found but could not be invoked.
203.It 127
204The
205.Ar command
206could not be found.
207.El
208.Pp
209Otherwise, the exit status of
210.Nm
211will be that of
212.Ar command .
213.Sh SEE ALSO
214.Xr csh 1 ,
215.Xr ksh 1 ,
216.Xr clock_gettime 2 ,
217.Xr getrusage 2 ,
218.Xr wait4 2
219.Sh STANDARDS
220The
221.Nm
222utility conforms to
223.St -p1003.2-92 .
224.Sh BUGS
225The granularity of seconds on microprocessors is crude and
226can result in times being reported for CPU usage which are too large by
227a second.
228