numActiveThreads: Count number of active threads

View source: R/numActiveThreads.R

numActiveThreadsR Documentation

Count number of active threads

Description

This uses ps -ef so only works on unix-alikes. It will search for the percent CPU use and select only those above 40

Usage

numActiveThreads(pattern = "--slave", minCPU = 50)

Arguments

pattern

Character string that will be matched to the ps call

minCPU

A numeric indicating what percent is the minimum to be considered "active"

Value

A numeric of the number of active threads that match the pattern

Author(s)

Eliot McIntire

Examples

## Not run: 
 ## Determine how many threads are used in each remote machine in a cluster
  cores = "localhost" # put other machine names here
  uniqueCores <- unique(cores)
  cl <- future::makeClusterPSOCK(uniqueCores, revtunnel = TRUE)
  clusterExport(cl, "numActiveThreads")
  out <- clusterEvalQ(cl, {
    numActiveThreads()
  })
  names(out) <- uniqueCores
  unlist(out)
  stopCluster(cl)


## End(Not run)

PredictiveEcology/pemisc documentation built on Sept. 19, 2022, 7 p.m.