I hacked together an Emacs function in order to send
tOne <- proc.time()[3]
before my "send-to-R" key, followed by
tTwo <- proc.time()[3]
afterwards, then printing the difference. The printing gets quite messy though.
Is there a better way in R to automatically time everything send to R? (such as in F# #time "on")
EDIT: Currently, it sends some extra newlines since the inferior buffer needs the strings to be sent:
> > 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 
> > 
Function:
(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)
  )