pprof {proffer} | R Documentation |
Profile R code and visualize with pprof.
Description
Run R code and display profiling results
in a local interactive pprof server.
Results are collected with record_pprof()
.
Usage
pprof(
expr,
host = "localhost",
port = proffer::random_port(),
browse = interactive(),
verbose = TRUE,
...
)
Arguments
expr |
R code to run and profile. |
host |
Host name. Set to |
port |
Port number for hosting the local pprof server. Chosen randomly by default. |
browse |
Logical, whether to open a browser to view the pprof server. |
verbose |
Logical, whether to print console messages
such as the URL of the local |
... |
Additional arguments passed on to |
Value
A processx::process$new()
handle. Use this handle
to take down the server with $kill()
.
Examples
if (identical(Sys.getenv("PROFFER_EXAMPLES"), "true")) {
# Start a pprof virtual server in the background.
px <- pprof(replicate(1e2, sample.int(1e4)))
# Terminate the server.
px$kill()
}