I made an R package with Rcpp where whole simulations are run in c++ and results are analyzed in R. Now I need to profile my functions so I can optimize them, but R profilers can't distinguish what happens inside the C++ functions, and I don't know how to run C++ profilers when the functions can only be ran from inside R.
So far, I have found some suggestions to use gperftools (questions and tutorials) but the guides are incomplete (maybe they assume a level of knowledge that I lack?), have missing links, and I keep running into walls. Hence this question. Here's where I'm at:
- Install gperftools (I installed from extra/gperftools with pacman)
- include gperftools/profiler.h on the C++ header
- Add ProfilerStart("myprof.log") and ProfilerStop() in the C++ code around what I want to profile
- Compile with -lprofiler
- Run "$ CPUPROFILE="myprof.log" R -f myscript.R"
The current wall is gcc tells me "Undefined Symbol: ProfilerStart", so I think there's something wrong with the linking?