processx icon indicating copy to clipboard operation
processx copied to clipboard

Add ability to get run time duration for `callr::r_bg`

Open sckott opened this issue 6 years ago • 1 comments

I'd like to be able to run callr::r_bg() and then get the duration of time it took to run func, or at least time from opening the R session to it being killed if its too difficult to get timing for the func itself.

One can get the start time with x$get_start_time(), but there is no way that I can see to get the end time. Right now as a hack I do:

library(callr)
x <- r_bg(function() { Sys.sleep(5); "1 done" })
x$wait()
end_time <- as.POSIXlt(Sys.time(), tz = "GMT")
start_time <- x$get_start_time()
as.numeric(end_time - start_time) # duration

let me know if I should instead open this in processx repo

sckott avatar Aug 01 '19 21:08 sckott

Yeah, I guess this is more of a processx feature, I'll move it over there.

gaborcsardi avatar Aug 02 '19 08:08 gaborcsardi