start_profiler() initiates profiling. It is a replacement for Rprof() that will include native stack traces where available. Internally, Rprof() is used to capture R call stacks.

stop_profiler() terminates profiling. The results are written to the Rprof()-compatible file given specified by the path argument.

start_profiler(path = "Rprof.out", ..., numfiles = 100L, bufsize = 10000L)

stop_profiler()

## Arguments

path Path to the output file. Ignored, for extensibility. Passed on to Rprof() call.

## Value

stop_profiler() returns (invisibly) the profiling data like it would have been read by profile::read_rprof(), validated with profile::validate_profile().

## Details

Profiling requires the pprof tool, which can be made available by installing the pprof package (recommended) or by running go get github.com/google/pprof and adding \${GOPATH}/bin to the PATH.

Set the keep.source and keep.source.pkgs options to TRUE (via option()) before installing packages from source or running code to obtain accurate locations in your stack traces. It is a good idea to set these options in your .Rprofile file.

Use the profile package to read the data or save the output in pprof format for further processing.

## Examples

if (FALSE) {
start_profiler("Rprof.out")
# code to be profiled
stop_profiler()