Skip to content
Prev 315296 / 398503 Next

function coverage

On 13-01-14 4:08 PM, Ross Boylan wrote:
I think codetools could do this reasonably well with the walkCode 
function, but I've never done it so I don't have sample code, and 
walkCode is mostly an internal function.

The other way to do it is to run Rprof.  It's only a sampling profiler, 
so you don't get complete coverage, but it sees what really happens at 
run-time.  The proftools package can generate a call tree.  (In R 3.0.0 
you'll probably be able to extend this coverage analysis to the 
statement level, but it's not there yet.)
Right, that makes it hard.  I don't know if walkCode could figure that 
stuff out, and the current Rprof won't know the original name if you do 
something like

f <- mean
f(3)

The new stuff should be able to help in cases where the called function 
is written in R and is slow enough to be caught by the profiler.  If you 
want to try it out and can compile R-devel for yourself, write to me and 
I'll send you a patch offline.
Duncan Murdoch