View source: R/parallel_config.R
| should_parallelize | R Documentation |
Internal function to determine if an operation should use parallel processing based on the number of items to process and current configuration.
should_parallelize(n, threshold = 10)
n |
Integer specifying the number of items to process. |
threshold |
Integer specifying the minimum number of items required for parallel processing to be beneficial (default: 10). Below this threshold, sequential processing is used even if parallelization is enabled. |
This function returns TRUE only if:
Parallel processing is enabled (via set_parallel_plan())
The number of items n is at least threshold
For small numbers of items, the overhead of parallelization typically outweighs the benefits, so sequential processing is used.
Logical value: TRUE if parallel processing should be used, FALSE otherwise.
set_parallel_plan(), is_parallel_enabled()
## Not run:
# With parallel processing enabled
set_parallel_plan("multisession")
should_parallelize(5) # FALSE (below threshold)
should_parallelize(20) # TRUE (above threshold)
# With parallel processing disabled
set_parallel_plan("sequential")
should_parallelize(100) # FALSE (sequential plan)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.