【问题标题】:Running Callgrind on simple R file在简单的 R 文件上运行 Callgrind
【发布时间】:2015-02-26 15:51:32
【问题描述】:

我想使用 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

这与我在使用更复杂的代码时遇到的错误完全相同,所以除了函数之外还有其他问题。

请问有人知道我做错了什么吗?谢谢。

【问题讨论】:

    标签: r profiling valgrind callgrind


    【解决方案1】:

    可能有点晚了,但如果你改用呢

    R -d "valgrind --tool=callgrind" -f filename.R
    

    【讨论】:

      猜你喜欢
      • 2011-05-31
      • 2016-09-10
      • 1970-01-01
      • 2021-10-26
      • 2018-09-30
      • 1970-01-01
      • 2020-05-14
      • 2019-02-13
      • 2020-12-02
      相关资源
      最近更新 更多