Open wch opened 6 years ago
later_test <- function(times = 10000L) {
start_time <- Sys.time()
i <- 0L
run <- function() {
i <<- i + 1L
if (i >= times) {
elapsed <- Sys.time() - start_time
print(elapsed)
} else {
later:::later(run, 0)
}
}
later:::later(run, 0)
}
library(promises)
promise_test <- function(times = 10000L) {
start_time <- Sys.time()
i <- 0L
action <- function(resolve, reject) {
i <<- i + 1L
if (i >= times) {
elapsed <- Sys.time() - start_time
print(elapsed)
resolve(invisible(NULL))
} else {
f <- function() {
p <- promise(action)
resolve(p)
}
later::later(f, 0)
}
}
promise(action)
}
@jcheng5, can you supply the examples that you showed me?