Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

freeCores

Get the Average Number of Free CPU Cores


Description

Get the Average Number of Free CPU Cores

Usage

freeCores(
  memory = c("5min", "15min", "1min"),
  fraction = 0.9,
  logical = getOption2("parallelly.availableCores.logical", TRUE),
  default = parallelly::availableCores()
)

Arguments

memory

(character) The time period used to infer the system load, with alternatives being 5 minutes (default), 15 minutes, or 1 minute.

fraction

(non-negative numeric) A scale factor.

logical

Passed as-is to availableCores().

default

(integer) The value to be returned if the system load is unknown, i.e. cpuLoad() return missing values.

Value

An positive integer with attributes loadavg (named numeric), maxCores (named integer), argument memory (character), and argument fraction (numeric).

Examples

free <- freeCores()
print(free)

## Not run: 
## Make availableCores() agile to the system load
options(parallelly.availableCores.custom = function() freeCores())

## End(Not run)

parallelly

Enhancing the 'parallel' Package

v1.25.0
LGPL (>= 2.1)
Authors
Henrik Bengtsson [aut, cre, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.