在一个大的包上运行R CMD roxygen可能需要相当长的时间。它的效率显然很低,因为它会遍历所有内容,而不管文件在上次roxygen调用后是否发生了更改。
有什么关于如何提高速度的建议吗?
发布于 2011-01-21 04:43:02
Roxygen2 > 3.0.0更快了,不再需要缓存。
在我本地的roxygen版本中,我有:
library(memoize)
cached.parse.ref <- memoize(parse.ref)
cached.parse.srcfile <- memoize(parse.srcfile)
parse.file <- function(file) {
srcfile <- srcfile(file)
res <- try(cached.parse.srcfile(srcfile), silent = TRUE)
if (inherits(res, "try-error")) {
stop("Can't pass", file, "\n", res, call. = FALSE)
}
res
}
parse.srcfile <- function(srcfile) {
srcrefs <- attributes(parse(srcfile$filename,
srcfile=srcfile))$srcref
if (length(srcrefs) > 0)
parse.refs(zip.list(prerefs(srcfile, srcrefs), srcrefs))
else
nil
}我认为这些是您需要的唯一更改,但我不确定。它能使roxygen加速一个数量级。
https://stackoverflow.com/questions/4749000
复制相似问题