3

I need to profile R code, preferably with a graphical interface. Which package + IDE would be the best for this task? I didn't know there would be different kinds of profiling in R (when I profile in other languages, I get all I need in the same interface), but my requirements are, in order of importance:

  1. Understand which are the functions where my code spends more time. Ideally, frequency of call would be also needed, not just total time (it makes an hell of a difference if function A is taking an hour of CPU time because it's being called one million times, or 10 times but each call takes 6 minutes);
  2. Be able to drill down at line level and see which lines take more time in a single function call;
  3. Finally, less important but nice to have, understand the memory footprint of the functions

PS concerning the IDE, I guess you people will suggest me to use RStudio and that's perfectly fine, but I didn't want to hardwire the IDE choice, because I really need to do profiling well, and if that requires me to change IDE, I'm willing to pay that price.

3

There's some useful information at SO:

https://stackoverflow.com/questions/7252602/digging-into-r-profiling-information

In the old days, it was common to use Rprof, and you can see ?Rprof for more information, but clearly you want something more user friendly.

https://stackoverflow.com/questions/6262203/measuring-function-execution-time-in-r

If you look at the list of packages you see several whose name suggest the possibility of a constructed interface: profileR, profilr, profr, profvis.

The profvis- package appears to be a successor to the profr-package, since it seems to be supported by Rstudio and profr (by Hadley) hasn't been updated recently. So trying profvis (possibly inside Rstudio but it should work in other IDEs) would probably be the immediate choice to try.

This article appeared relative relatively recently and has a useful list of packages and comparisons. The comparison of feature set suggest that profvis may be the most complete strategy.

|improve this answer|||||
  • when I saw your avatar I said "no way! That reputation score can't be right! What, did he give all of his reputation away in countless bounties? Does reputation get reset after you exceed a certain score?!". Then I realized this is Software Recommendations ;-P – DeltaIV Jun 25 '18 at 21:03
  • I have been fairly generous with the few bounties I’ve offered but I’ve had the same sort of whiplash experience going to MetaSO where my opinions are not typically well-received and I get little cared for my “years of service”. – 42- Jun 25 '18 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.