Get the Average Number of Free CPU Cores
freeCores(
memory = c("5min", "15min", "1min"),
fraction = 0.9,
logical = getOption2("parallelly.availableCores.logical", TRUE),
default = parallelly::availableCores()
)
(character) The time period used to infer the system load, with alternatives being 5 minutes (default), 15 minutes, or 1 minute.
(non-negative numeric) A scale factor.
Passed as-is to availableCores()
.
(integer) The value to be returned if the system load is
unknown, i.e. cpuLoad()
return missing values.
An positive integer with attributes loadavg
(named numeric),
maxCores
(named integer), argument memory
(character), and
argument fraction
(numeric).
free <- freeCores()
print(free)
#> [1] 5
#> attr(,"loadavg")
#> 1min 5min 15min
#> 1.81 1.47 1.27
#> attr(,"maxCores")
#> system
#> 8
#> attr(,"memory")
#> [1] "5min"
#> attr(,"fraction")
#> [1] 0.9
if (FALSE) { # \dontrun{
## Make availableCores() agile to the system load
options(parallelly.availableCores.custom = function() freeCores())
} # }