I want to use Callgrind to find bottlenecks in some complicated Rcpp code. Since I couldn't get it to work, I decided to write a simple R file instead, to make sure it was doing what it should.
However, I still can't get it to work.
My simple function is:
args <- commandArgs(trailingOnly=T)
test_callgrind <- function(args) {
x <- args[1]
a <- 0
for (i in 1:x) {
a <- i
}
return(a)
}
a <- test_callgrind(args)
save(a, file="a.rdata")
I then type:
valgrind --tool=callgrind Rscript filename.R 1000
This seems to run fine, and produces callgrind.out.XYZ, as the documentation says it should.
I then type:
callgrind_annotate callgrind.out.XYZ
and get the following:
Use of uninitialized value $events in string ne at /usr/bin/callgrind_annotate line 446.
Line 0: missing events line
This is exactly the same error as I got with my more complicated code, so something besides the function is at fault.
Does anyone have any ideas what I'm doing wrong please? Thanks.