The goal of jointprof is to assist profiling R packages that include native code (C++, C, Fortran, ...). It collects profiling output simultaneously using Rprof and gperftools and provides a unified view of profiling data.
See the guide for a more detailed overview, or take a look at the internals document if you're curious.
Other Linux distributions may work if you install the right system dependencies (let me know which!).
-
Install system dependencies:
sudo apt install \ libgoogle-perftools-dev \ libprotoc-dev libprotobuf-dev protobuf-compiler \ golang-go \ graphviz
-
Install
pprof
:go get github.com/google/pprof
-
Install the package:
# install.packages("remotes") remotes::install_github("r-prof/jointprof")
-
Install system dependencies:
brew install graphviz
-
Install
gperftools
(currently from a branch, pull request pending):git clone https://github.com/krlmlr/gperftools.git -b f-export-stack cd gperftools ./autogen.sh ./configure make sudo make install cd ..
-
Install
pprof
:go get github.com/google/pprof
-
Install the package:
# install.packages("remotes") remotes::install_github("r-prof/jointprof")
Windows and Solaris are not supported.
library(jointprof)
target_file <- "Rprof.out"
# Collect profile data
start_profiler(target_file)
## code to be profiled
stop_profiler()
# Analyze profile data
summaryRprof(target_file)
profvis::profvis(prof_input = target_file)
proftools::readProfileData(target_file)
prof.tree::prof.tree(target_file)
# Convert to pprof format and analyze
pprof_target_file <- "Rprof.pb.gz"
profile_data <- profile::read_rprof(target_file)
profile::write_rprof(profile_data, pprof_target_file)
system2(
find_pprof(),
c(
"-http",
"localhost:8080",
shQuote(pprof_target_file)
)
)
This project is being realized with financial support from the