Rev 42766 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/utils/man/Rprof.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2007 R Core Development Team% Distributed under GPL 2 or later\name{Rprof}\alias{Rprof}\title{Enable Profiling of R's Execution}\description{Enable or disable profiling of the execution of \R expressions.}\usage{Rprof(filename = "Rprof.out", append = FALSE, interval = 0.02,memory.profiling=FALSE)}\arguments{\item{filename}{The file to be used for recording the profiling results.Set to \code{NULL} or \code{""} to disable profiling.}\item{append}{logical: should the file be over-written or appended to?}\item{interval}{real: time interval between samples.}\item{memory.profiling}{logical: write memory use information to the file?}}\details{Enabling profiling automatically disables any existing profiling toanother or the same file.Profiling works by writing out the call stack every \code{interval}seconds, to the file specified. Either the \code{\link{summaryRprof}}function or the Perl script \code{R CMD Rprof} can be used to processthe output file to produce a summary of theusage; use \code{R CMD Rprof --help} for usage information.#ifdef windowsExactly what the time interval measures is subtle: it is time that the\R process is running and executing an \R command. It is not however justCPU time, for if \code{readline()} is waiting for input, that counts(on Windows, but not on Unix).Note that the timing interval cannot be too small, for the time spentin each profiling step is added to the interval. What is feasible ismachine-dependent, but 10ms seems as small as advisable on a 1GHz machine.#endif#ifdef unixNote that the timing interval cannot be too small: once the timer goesoff, the information is not recorded until the next timing click(probably in the range 1--10msecs).#endif}\note{#ifdef windowsUsing \code{R CMD Rprof} needs Windows Perl to be installed: this canbe installed from \code{Rtools.exe}.#endif#ifdef unixProfiling is not available on all platforms. By default, it isattempted to compile support for profiling. Configure \R with\option{--disable-R-profiling} to change this.As \R profiling uses the same mechanisms as C profiling, the twocannot be used together, so do not use \code{Rprof} in an executablebuilt for profiling.#endif}\seealso{The chapter on \dQuote{Tidying and profiling R code} in\dQuote{Writing \R Extensions} (see the \file{doc/manual} subdirectoryof the \R source tree).\code{\link{summaryRprof}}\code{\link{tracemem}}, \code{\link{Rprofmem}} for other ways to trackmemory use.}\examples{\dontrun{Rprof()## some code to be profiledRprof(NULL)## some code NOT to be profiledRprof(append=TRUE)## some code to be profiledRprof(NULL)\dots## Now post-process the output as described in Details}}\keyword{utilities}