LinuxReviws.org --get your your Linux knowledge
> Linux Reviews > Manual Pages (man) >

time

time a simple command or give resource usage


  1. time.1.man
  2. time.2.man
  3. time.7.man
  4. time.9.man


1. time.1.man

Manpage of TIME

TIME

Section: Linux User's Manual (1)
Updated: 2008-11-14
Index Return to Main Contents
 

NAME

time - time a simple command or give resource usage  

SYNOPSIS

time [options] command [arguments...]  

DESCRIPTION

The time command runs the specified program command with the given arguments. When command finishes, time writes a message to standard error giving timing statistics about this program run. These statistics consist of (i) the elapsed real time between invocation and termination, (ii) the user CPU time (the sum of the tms_utime and tms_cutime values in a struct tms as returned by times(2)), and (iii) the system CPU time (the sum of the tms_stime and tms_cstime values in a struct tms as returned by times(2)).

Note: some shells (e.g., bash(1)) have a built-in time command that provides less functionality than the command described here. To access the real command, you may need to specify its pathname (something like /usr/bin/time).  

OPTIONS

-p
When in the POSIX locale, use the precise traditional format
"real %f
user %f
sys %f
"
(with numbers in seconds) where the number of decimals in the output for %f is unspecified but is sufficient to express the clock tick accuracy, and at least one.
 

EXIT STATUS

If command was invoked, the exit status is that of command. Otherwise it is 127 if command could not be found, 126 if it could be found but could not be invoked, and some other nonzero value (1-125) if something else went wrong.  

ENVIRONMENT

The variables LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, LC_NUMERIC, NLSPATH, and PATH are used. The last one to search for command. The remaining ones for the text and formatting of the output.  

GNU VERSION

Below a description of the GNU 1.7 version of time. Disregarding the name of the utility, GNU makes it output lots of useful information, not only about time used, but also on other resources like memory, I/O and IPC calls (where available). The output is formatted using a format string that can be specified using the -f option or the TIME environment variable.

The default format string is:

%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps

When the -p option is given the (portable) output format

real %e
user %U
sys %S

is used.  

The format string

The format is interpreted in the usual printf-like way. Ordinary characters are directly copied, tab, newline and backslash are escaped using \t,
and \\, a percent sign is represented by %%, and otherwise % indicates a conversion. The program time will always add a trailing newline itself. The conversions follow. All of those used by tcsh(1) are supported.

Time

%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

%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

%I
Number of file system inputs by the process.
%O
Number of file system 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.
 

GNU Options

-f FORMAT, --format=FORMAT
Specify output format, possibly overriding the format specified in the environment variable TIME.
-p, --portability
Use the portable output format.
-o FILE, --output=FILE
Do not send the results to stderr, but overwrite the specified file.
-a, --append
(Used together with -o.) Do not overwrite but append.
-v, --verbose
Give very verbose output about all the program knows about.
 

GNU Standard Options

--help
Print a usage message on standard output and exit successfully.
-V, --version
Print version information on standard output, then exit successfully.
--
Terminate option list.
 

BUGS

Not all resources are measured by all versions of UNIX, so some of the values might be reported as zero. The present selection was mostly inspired by the data provided by 4.2 or 4.3BSD.

GNU time version 1.7 is not yet localized. Thus, it does not implement the POSIX requirements.

The environment variable TIME was badly chosen. It is not unusual for systems like autoconf(1) or make(1) to use environment variables with the name of a utility to override the utility to be used. Uses like MORE or TIME for options to programs (instead of program pathnames) tend to lead to difficulties.

It seems unfortunate that -o overwrites instead of appends. (That is, the -a option should be the default.)

Mail suggestions and bug reports for GNU time to
bug-utils@prep.ai.mit.edu
Please include the version of time, which you can get by running
time --version
and the operating system and C compiler you used.  

SEE ALSO

tcsh(1), times(2), wait3(2)  

COLOPHON

This page is part of release 3.32 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXIT STATUS
ENVIRONMENT
GNU VERSION
The format string
GNU Options
GNU Standard Options
BUGS
SEE ALSO
COLOPHON

This document was created by man2html using the manual pages.
Time: 17:32:47 GMT, October 23, 2013

2. time.2.man

Manpage of TIME

TIME

Section: Linux Programmer's Manual (2)
Updated: 2010-02-25
Index Return to Main Contents
 

NAME

time - get time in seconds  

SYNOPSIS

#include <time.h>

time_t time(time_t *t);  

DESCRIPTION

time() returns the time as the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).

If t is non-NULL, the return value is also stored in the memory pointed to by t.  

RETURN VALUE

On success, the value of time in seconds since the Epoch is returned. On error, ((time_t) -1) is returned, and errno is set appropriately.  

ERRORS

EFAULT
t points outside your accessible address space.
 

CONFORMING TO

SVr4, 4.3BSD, C89, C99, POSIX.1-2001. POSIX does not specify any error conditions.  

NOTES

POSIX.1 defines seconds since the Epoch as a value to be interpreted as the number of seconds between a specified time and the Epoch, according to a formula for conversion from UTC equivalent to conversion on the naive basis that leap seconds are ignored and all years divisible by 4 are leap years. This value is not the same as the actual number of seconds between the time and the Epoch, because of leap seconds and because clocks are not required to be synchronized to a standard reference. The intention is that the interpretation of seconds since the Epoch values be consistent; see POSIX.1 Annex B 2.2.2 for further rationale.  

SEE ALSO

date(1), gettimeofday(2), ctime(3), ftime(3), time(7)  

COLOPHON

This page is part of release 3.32 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
CONFORMING TO
NOTES
SEE ALSO
COLOPHON

This document was created by man2html using the manual pages.
Time: 17:32:47 GMT, October 23, 2013

3. time.7.man

Manpage of TIME

TIME

Section: Linux Programmer's Manual (7)
Updated: 2010-02-25
Index Return to Main Contents
 

NAME

time - overview of time and timers  

DESCRIPTION

 

Real time and process time

Real time is defined as time measured from some fixed point, either from a standard point in the past (see the description of the Epoch and calendar time below), or from some point (e.g., the start) in the life of a process (elapsed time).

Process time is defined as the amount of CPU time used by a process. This is sometimes divided into user and system components. User CPU time is the time spent executing code in user mode. System CPU time is the time spent by the kernel executing in system mode on behalf of the process (e.g., executing system calls). The time(1) command can be used to determine the amount of CPU time consumed during the execution of a program. A program can determine the amount of CPU time it has consumed using times(2), getrusage(2), or clock(3).  

The Hardware Clock

Most computers have a (battery-powered) hardware clock which the kernel reads at boot time in order to initialize the software clock. For further details, see rtc(4) and hwclock(8).  

The Software Clock, HZ, and Jiffies

The accuracy of various system calls that set timeouts, (e.g., select(2), sigtimedwait(2)) and measure CPU time (e.g., getrusage(2)) is limited by the resolution of the software clock, a clock maintained by the kernel which measures time in jiffies. The size of a jiffy is determined by the value of the kernel constant HZ.

The value of HZ varies across kernel versions and hardware platforms. On i386 the situation is as follows: on kernels up to and including 2.4.x, HZ was 100, giving a jiffy value of 0.01 seconds; starting with 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001 seconds. Since kernel 2.6.13, the HZ value is a kernel configuration parameter and can be 100, 250 (the default) or 1000, yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds. Since kernel 2.6.20, a further frequency is available: 300, a number that divides evenly for the common video frame rates (PAL, 25 HZ; NTSC, 30 HZ).

The times(2) system call is a special case. It reports times with a granularity defined by the kernel constant USER_HZ. Userspace applications can determine the value of this constant using sysconf(_SC_CLK_TCK).  

High-Resolution Timers

Before Linux 2.6.21, the accuracy of timer and sleep system calls (see below) was also limited by the size of the jiffy.

Since Linux 2.6.21, Linux supports high-resolution timers (HRTs), optionally configurable via CONFIG_HIGH_RES_TIMERS. On a system that supports HRTs, the accuracy of sleep and timer system calls is no longer constrained by the jiffy, but instead can be as accurate as the hardware allows (microsecond accuracy is typical of modern hardware). You can determine whether high-resolution timers are supported by checking the resolution returned by a call to clock_getres(2) or looking at the "resolution" entries in /proc/timer_list.

HRTs are not supported on all hardware architectures. (Support is provided on x86, arm, and powerpc, among others.)  

The Epoch

UNIX systems represent time in seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).

A program can determine the calendar time using gettimeofday(2), which returns time (in seconds and microseconds) that have elapsed since the Epoch; time(2) provides similar information, but only with accuracy to the nearest second. The system time can be changed using settimeofday(2).  

Broken-down time

Certain library functions use a structure of type tm to represent broken-down time, which stores time value separated out into distinct components (year, month, day, hour, minute, second, etc.). This structure is described in ctime(3), which also describes functions that convert between calendar time and broken-down time. Functions for converting between broken-down time and printable string representations of the time are described in ctime(3), strftime(3), and strptime(3).  

Sleeping and Setting Timers

Various system calls and functions allow a program to sleep (suspend execution) for a specified period of time; see nanosleep(2), clock_nanosleep(2), and sleep(3).

Various system calls allow a process to set a timer that expires at some point in the future, and optionally at repeated intervals; see alarm(2), getitimer(2), timerfd_create(2), and timer_create(2).  

SEE ALSO

date(1), time(1), adjtimex(2), alarm(2), clock_gettime(2), clock_nanosleep(2), getitimer(2), getrlimit(2), getrusage(2), gettimeofday(2), nanosleep(2), stat(2), time(2), timer_create(2), timerfd_create(2), times(2), utime(2), adjtime(3), clock(3), clock_getcpuclockid(3), ctime(3), pthread_getcpuclockid(3), sleep(3), strftime(3), strptime(3), timeradd(3), usleep(3), rtc(4), hwclock(8)  

COLOPHON

This page is part of release 3.32 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.


 

Index

NAME
DESCRIPTION
Real time and process time
The Hardware Clock
The Software Clock, HZ, and Jiffies
High-Resolution Timers
The Epoch
Broken-down time
Sleeping and Setting Timers
SEE ALSO
COLOPHON

This document was created by man2html using the manual pages.
Time: 17:32:47 GMT, October 23, 2013

4. time.9.man

Manpage of time

time

Section: Tcl Built-In Commands (n)
Updated:
Index Return to Main Contents



 

NAME

time - Time the execution of a script  

SYNOPSIS

time script ?count?



 

DESCRIPTION

This command will call the Tcl interpreter count times to evaluate script (or once if count is not specified). It will then return a string of the form


503 microseconds per iteration

which indicates the average amount of time required per iteration, in microseconds. Time is measured in elapsed time, not CPU time.  

EXAMPLE

Estimate how long it takes for a simple Tcl for loop to count to a thousand:

time {
    for {set i 0} {$i<1000} {incr i} {
        # empty body
    }
}

 

SEE ALSO

clock(n)

 

KEYWORDS

script, time


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLE
SEE ALSO
KEYWORDS

This document was created by man2html using the manual pages.
Time: 17:32:47 GMT, October 23, 2013

ENGLISH - ENGLISH - cs - da - ENGLISH - ENGLISH - ENGLISH - ENGLISH - ja - nl - pl - ro - ENGLISH - zh_CN

Meet new people