Hi Dan,
All Rprof does is check what the current call stack is (what function is
currently being executed, and what called it, etc.) every fraction of a
second, and write that to file (as text). That information is then
analyzed by summaryRprof to get information such as how much time is
being spent (how many samples have been taken) in given functions.
In general the basic info your get from any profiling will be
-the "self" time, the time spent in the given function itself
-the "total" time, the time spent in the given function plus everything
downstream of it (time in functions that it calls)
The other info that one typically wants (but summaryRprof does not give,
as far as I can tell) is what the call hierarchy and the number of times
each function is called. Based on what is written to file by Rprof it
isn't possible to extract the latter, but the call hierarchy is easy
enough. I wrote a python script to do it (attached), but there may be a
better R package that I haven't found yet. Or you could write one in
R. The call hierarchy is important. Obviously it is good to know the
program flow and who is calling what, but it can also be good to know
whether a particular function is being called from multiple places.
Speeding up loops and particular functions is great, but making higher
level structural changes that reduce the number of times a function is
called can also be very helpful.
It will also be good to note how much time is being spent in R library
functions. You obviously won't be able to optimize them directly, so
avoiding extra calls is your only hope.
Let me know if this all makes sense.
Cheers,
Derrick