Rprof takes call stack samples at time intervals - good news.
What I would do is access the original stackshots that it collects and select a few randomly and examine them. I am looking for call sites (not just functions, but places where one function calls another) that appear on several patterns. For example, if the call site is displayed on 50% of the samples, then this is what it costs, because its possible removal will save about 50% of the total time. (It seems obvious, right? But this is not well known.)
Not every expensive call site is optimized, but some of them if the program was not as fast as possible.
(Donโt be distracted by questions such as the number of samples that you need to look at. If something saves you a reasonable fraction of the time, it appears on a similar fraction of the samples. The exact number doesnโt matter what you find. Also, don't be distracted on graph, recursion, time, and counting calculations. For each call site, it is important that the proportion of stack samples display it.)
Mike dunlavey
source share