我在这里和这里阅读了相关的帖子,并在此处查看了 Dirk Eddelbuettel 的演讲,但我什至无法从 .log 文件中获取 .log 文件gperftools
。这是我的R
文件,名为Rcpp_practice.R
:
library(Rcpp)
Sys.setenv("PKG_LIBS"="-lprofiler")
sourceCpp('eigen.cpp')
a <- matrix(rnorm(300^2), 300, 300)
getEigenValues(a)
以下是 的内容eigen.cpp
:
#include <RcppArmadillo.h>
#include <gperftools/profiler.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
arma::vec getEigenValues(arma::mat M) {
return arma::eig_sym(M);
}
然后,在终端上(我使用的是 OSX):
CPUPROFILE="eigenprof.log" R -f "Rcpp_practice.R"
我希望看到eigenprof.log
坐在我的工作目录中,但我没有。另外,我没有收到我在表单的其他帖子中看到的消息PROFILE: interrupts/evictions/bytes = 012/34/567891
我确认我安装了最新版本gperftools
。($ brew upgrade google-perftools
给出Error: gperftools 2.5 already installed
)。
我错过了什么?
更新
在我修改我的代码以匹配@nrussell's 后,我收到以下错误消息:
Error in dyn.load("/private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so") :
unable to load shared object '/private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so':
dlopen(/private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so, 6): Symbol not found: _ProfilerStart
Referenced from: /private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so
Expected in: flat namespace
in /private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so
Calls: sourceCpp -> source -> withVisible -> eval -> eval -> dyn.load
Execution halted
sourceCpp
如果我以交互方式运行脚本,这将出现在行上。