\HeaderA{setTimeLimit}{Set CPU and/or Elapsed Time Limits}{setTimeLimit}
\aliasA{setSessionTimeLimit}{setTimeLimit}{setSessionTimeLimit}
\keyword{utilities}{setTimeLimit}
\begin{Description}\relax
Functions to set CPU and/or elapsed time limits for top-level
computations or the current session.
\end{Description}
\begin{Usage}
\begin{verbatim}
setTimeLimit(cpu = Inf, elapsed = Inf, transient = FALSE)

setSessionTimeLimit(cpu = Inf, elapsed = Inf)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{cpu}] double.  Limit on total cpu time.
\item[\code{elapsed}] double.  Limit on elapsed time.
\item[\code{transient}] logical.  If \code{TRUE}, the limits apply only to
the rest of the current computation.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{setTimeLimit} sets limits which apply to each top-level
computation, that is a command line (including any continuation lines)
entered at the console or from a file.  If it is called from within a
computation the limits apply to the rest of the computation and
(unless \code{transient = TRUE} to subsequent top-level computations.

\code{setSessionTimeLimit} sets limits for the rest of the
session.  Once a session limit is reached it is reset to \code{Inf}.

Setting any limit has a small overhead -- well under 1\% on the
systems measured.

Time limits are checked whenever a user interrupt could occur.
This will happen frequently in \R{} code and during \code{\LinkA{Sys.sleep}{Sys.sleep}},
but only at points in compiled C and Foreign code identified by the
code author.

\sQuote{Total cpu time} includes that used by child processes where
the latter is reported.

It is possible (but very unusual) to build \R{} without support for
\code{\LinkA{proc.time}{proc.time}}, in which case these functions have no effect.
\end{Details}

