serve_rprof {proffer} | R Documentation |
Visualize Rprof() output with pprof.
Description
Use pprof to visualize profiling data
produced by Rprof()
or record_rprof()
.
Usage
serve_rprof(
rprof,
host = "localhost",
port = proffer::random_port(),
browse = interactive(),
verbose = TRUE
)
Arguments
rprof |
Path to profiling samples generated
by |
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 |
Details
Uses a local interactive server. Navigate a browser to a URL in the message. The server starts in a background process
Value
A processx::process$new()
handle. Use this handle
to take down the server with $kill()
.
Examples
if (identical(Sys.getenv("PROFFER_EXAMPLES"), "true")) {
rprof <- record_rprof(replicate(1e2, sample.int(1e4)))
# Start a pprof virtual server in the background.
px <- serve_rprof(rprof)
# Terminate the server.
px$kill()
}