record_pprof: Profile R code and record pprof samples.

View source: R/record.R

record_pprofR Documentation

Profile R code and record pprof samples.

Description

Run R code and record pprof samples. Profiles are recorded with record_rprof() and then converted with to_pprof().

Usage

record_pprof(expr, seconds_timeout = Inf, pprof = tempfile(), ...)

Arguments

expr

An R expression to profile.

seconds_timeout

Maximum number of seconds of elapsed time to profile expr. When the timeout is reached, proffer stops running expr and returns the profiling samples taken during the seconds_timeout time window.

pprof

Path to a file with pprof samples. Also returned from the function.

...

Additional arguments passed on to Rprof().

Value

Path to a file with pprof samples.

Examples

if (identical(Sys.getenv("PROFFER_EXAMPLES"), "true")) {
# Returns a path to pprof samples.
record_pprof(replicate(1e2, sample.int(1e4)))
}

wlandau/proffer documentation built on June 10, 2025, 6:05 p.m.