\Header{system.time}{CPU Time Used}
\alias{unix.time}{system.time}
\keyword{utilities}{system.time}
\begin{Description}\relax
Return CPU (and other) times that \code{expr} used.
\end{Description}
\begin{Usage}
\begin{verbatim}
system.time(expr)
unix.time(expr)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{expr}] Valid \R{} expression to be \dQuote{timed}
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{system.time} calls the builtin \code{\Link{proc.time}},
evaluates \code{expr}, and then calls \code{proc.time} once more,
returning the difference between the two \code{proc.time} calls.

The values returned by the \code{proc.time} are (on Unix) those
returned by the C library function \code{times}(3v), if available.

\code{unix.time} is an alias of \code{system.time}, for
compatibility reasons.
\end{Details}
\begin{Value}
A numeric vector of length 5 containing the user cpu, system cpu, elapsed,
subproc1, subproc2 times. The subproc times are the user and
system cpu time used by child processes (and so are usually zero).

The resolution of the times will be system-specific; it is common for
them to be recorded to of the order of 1/100 second, and elapsed
time is rounded to the nearest 1/100.
\end{Value}
\begin{Note}\relax
It is possible to compile \R{} without support for \code{system.time},
when all the values will be \code{NA}.
\end{Note}
\begin{SeeAlso}\relax
\code{\Link{proc.time}}, \code{\Link{time}} which is for time series.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(stats)
system.time(for(i in 1:100) mad(runif(1000)))
## Not run: 
exT <- function(n = 1000) {
  # Purpose: Test if system.time works ok;   n: loop size
  system.time(for(i in 1:n) x <- mean(rt(1000, df=4)))
}
#-- Try to interrupt one of the following (using Ctrl-C / Escape):
exT()                 #- about 3 secs on a 1GHz PIII
system.time(exT())    #~ +/- same
## End(Not run)\end{ExampleCode}
\end{Examples}

