1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
load_my_example_pkg <- function(pkg, ...) {
skip_if(!requireNamespace("devtools", quietly = TRUE),
message = "Package devtools must be installed to run unit tests.")
from <- system.file(file.path('examples', pkg), package = 'RcppProgress')
dir <- tempfile()
dir.create(dir)
file.copy(from, dir, recursive = TRUE)
path <- file.path(dir, pkg)
devtools::load_all(path, quiet = TRUE, ...)
}
get_function_from_pkg <- function(pkg, fun) {
get(fun, getNamespace(pkg))
}
test_sequential <- function(max = 100, nb = 1000, display_progress= TRUE, ...) {
pkg <- 'RcppProgressExample'
load_my_example_pkg(pkg, ...)
fun <- get_function_from_pkg(pkg, 'test_sequential')
fun(max, nb, display_progress)
}
# R wrapper for the example function #2
test_multithreaded <- function(max = 100, nb = 1000, threads = 0,
display_progress = TRUE, ...)
{
pkg <- 'RcppProgressExample'
load_my_example_pkg(pkg, ...)
fun <- get_function_from_pkg(pkg, 'test_multithreaded')
fun(max, nb, threads, display_progress)
}
amardillo_multithreaded <- function(max = 100, nb = 1000, threads = 0,
display_progress = TRUE, ...)
{
skip_if(!requireNamespace("RcppArmadillo", quietly = TRUE),
message = "Package RcppArmadillo must be installed to run this test.")
pkg <- 'RcppProgressArmadillo'
load_my_example_pkg(pkg, ...)
fun <- get_function_from_pkg(pkg, 'test_multithreaded')
fun(max, nb, threads, display_progress)
}
eta_progress_bar <- function(max = 100, nb = 1000, display_progress = TRUE)
{
pkg <- 'RcppProgressETA'
load_my_example_pkg(pkg)
fun <- get_function_from_pkg(pkg, 'test_sequential')
fun(max, nb, display_progress)
}
|