我拼凑了一个 Emacs 函数以便发送
tOne <- proc.time()[3]
在我的“send-to-R”键之前,然后是
tTwo <- proc.time()[3]
之后,然后打印差异。印刷变得相当混乱。
R中是否有更好的方法来自动计时发送到R的所有内容?(例如在 F# 中#time "on"
)
编辑:目前,它发送一些额外的换行符,因为劣质缓冲区需要发送字符串:
> > a<-ocorrelate.parallel(replicate(2, rnorm(100000)), 0.5)
>
+ user 0.072 sys 0.020 elapsed 14.925
> > a<-ocorrelate.parallel(replicate(2, rnorm(100000)), 0.5)
>
+ user 0.088 sys 0.032 elapsed 16.868
> >
功能:
(defun ess-timed-cc (vis)
(interactive "P")
(process-send-string "R" "tone <- proc.time()[1:3];")
(ess-eval-region-or-function-or-paragraph-and-step vis)
(process-send-string "R" "ttwo <- proc.time()[1:3]; cat(paste(c(\"\",
format(ttwo-tone)), c(\"user\", \"sys\", \"elapsed\", \"\n\")));")
(other-window 1)
(inferior-ess-send-input)
(inferior-ess-send-input)
(goto-char (point-max))
(other-window -1)
)