Skip to content

Add ability to get run time duration for callr::r_bg #218

@sckott

Description

@sckott

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions