我想使用Callgrind来查找一些复杂的Rcpp代码中的瓶颈。因为我不能让它工作,所以我决定写一个简单的R文件,以确保它做它应该做的事情。
然而,我仍然不能让它工作。
我的简单函数是:
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")然后我键入:
valgrind --tool=callgrind Rscript filename.R 1000这似乎运行得很好,并生成callgrind.out.XYZ,正如documentation所说的那样。
然后我键入:
callgrind_annotate callgrind.out.XYZ并获取以下内容:
Use of uninitialized value $events in string ne at /usr/bin/callgrind_annotate line 446.
Line 0: missing events line这与我在更复杂的代码中得到的错误完全相同,所以除了函数之外,还有其他东西出错。
有谁知道我做错了什么吗?谢谢。
发布于 2015-09-22 17:37:46
可能有点晚了,但是如果您改为使用
R -d "valgrind --tool=callgrind" -f filename.Rhttps://stackoverflow.com/questions/28746870
复制相似问题