I'm trying to track down the reason(s) why a package I've put together loads slowly (relative to others, it's noticeably slower), and running this (using ggplot2 as an example) doesn't appear to give any insight:
Rprof(line.profiling=TRUE)
library(ggplot2)
Rprof(NULL)
summaryRprof("Rprof.out", lines = "show")
which yields:
$by.self
self.time self.pct total.time total.pct
<no location> 0.5 100 0.5 100
$by.total
total.time total.pct self.time self.pct
<no location> 0.5 100 0.5 100
$by.line
self.time self.pct total.time total.pct
<no location> 0.5 100 0.5 100
$sample.interval
[1] 0.02
$sampling.time
[1] 0.5
(And Rprof.out contains a mess of information I'm having trouble understanding.)
Can anyone suggest how I might "profile" what the function library is doing? Or, am I taking the wrong approach?
As it says in the Line profiling section of ?summaryRprof:
If the code being run has source reference information retained (via
keep.source = TRUEinsourceorKeepSource = TRUEin a packageDESCRIPTIONfile or some other way), then information about the origin of lines is recorded during profiling.
By default, source code is not kept when building/installing packages. You'll see non-trivial timings if you just run summaryRprof(). You could always re-install the base package with KeepSource=TRUE, but that might be more trouble than it's worth.
Another alternative would be to use debugonce(library) to step through the library call line-by-line. This is a bit brute-force, but it might be more obvious than combing through the profiling output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With