The example below parallelizes 64 Sys.sleep(1) instructions using the furrr package.
The package progressr is used to display the progression of the parallel execution.
This package allows to update some text details where I want to show the count of the number of terminated instructions.
But I do not know how to share a counter between the furrr process so with my 8-core cpu it shows 8/64 at max as you can see:
library(furrr)
library(progressr)
handlers("progress")
long_process <- function(items) {
nb_of_cores <- parallel::detectCores()
plan(multisession, workers = nb_of_cores)
N <- length(items)
p <- progressr::progressor(along = items)
n <- 0
item_process <- function(item) {
n <<- n + 1
p(paste(n, "/", N))
Sys.sleep(1)
}
future_walk(items, item_process)
}
with_progress(long_process(1:64))

Example showing how to customize the progress package handler taken from https://progressr.futureverse.org/#further-configuration-of-progress-handlers:
This gives a progress bar in the terminal that looks like:
Note that progress is superseded by the cli package. To achieve the same using the cli handler, use:
That will render like: