tests/performance/test-cpu.R

# Restart R.
rstudioapi::restartSession()

# Set up pipeline.
library(targets)
tar_script({
  library(targets)
  message("starting psock")
  future::plan(future::multisession)
  list(tar_target(x, Sys.sleep(360)))
})

# CPU usage should drop down to almost nothing
# as exponential backoff kicks in.
tar_make_future(callr_function = NULL)

# Restart R.
rstudioapi::restartSession()

# Set up pipeline.
library(targets)
tar_script({
  library(targets)
  options(clustermq.scheduler = "multiprocess")
  list(tar_target(x, Sys.sleep(360)))
})

# CPU usage should drop down to almost nothing.
tar_make_clustermq(callr_function = NULL)

Try the targets package in your browser

Any scripts or data that you put into this service are public.

targets documentation built on Oct. 12, 2023, 5:07 p.m.