xrprof
is the companion package to
xrprof
, an external sampling
profiler for R programs.
xrprof
is not yet available on CRAN. For
now, you can install the development version from
GitHub with:
# install.packages("devtools")
devtools::install_github("atheriel/xrprof-package")
Suppose you have some R code running that you want to profile. You can grab the process identifier (PID) with something like
$ pgrep rsession
67017
You can then use xrprof()
as a replacement for Rprof()
(and related
tools, such as profvis). For
example, to profile the process at 50 Hz for 5 seconds:
fname <- tempfile()
xrprof(fname, pid = 67017, frequency = 50, duration = 5)
# Wait 5 seconds...
You can then analyze the results using traditional R tools:
summaryRprof(fname)
# Or
profvis::profvis(prof_output = fname)
On many systems, this will require you to enter your password, but you
can give xrprof
permission to run without it by running
enable_no_sudo()
.
xrprof
is made available under the terms of the GPL, version 2.