Commit 303ff41a authored by Dorchies David's avatar Dorchies David
Browse files

test: adjust benchmark test

Refs #136
parent 82364d6f
Pipeline #27412 passed with stages
in 35 minutes and 32 seconds
......@@ -18,6 +18,10 @@ default:
- R CMD INSTALL .
- Rscript tests/scheduled_tests/regression.R dev
- Rscript tests/scheduled_tests/regression.R compare
artifacts:
paths:
- tests/tmp/stable/timing.tsv
- tests/tmp/dev/timing.tsv
.check:
stage: check
......@@ -27,6 +31,10 @@ default:
- Rscript tests/scheduled_tests/benchmarkRunModel.R
- R CMD INSTALL .
- Rscript tests/scheduled_tests/benchmarkRunModel.R
artifacts:
paths:
- tests/tmp/benchmark.tsv
- tests/tmp/mean_execution_time.tsv
.check_not_cran:
variables:
......
......@@ -24,7 +24,7 @@ colnames(dfBM) <- sModelNames
dfBM <- cbind(version = as.character(packageVersion('airGR')), dfBM)
file <- "tests/tmp/benchmark.txt"
file <- "tests/tmp/benchmark.tsv"
dir.create("tests/tmp", showWarnings = FALSE)
write.table(dfBM, file = file,
row.names = FALSE, col.names = !file.exists(file), quote = FALSE,
......@@ -39,7 +39,7 @@ if(length(unique(df$version)) > 1) {
names(lV) <- unique(df$version)
dfMean <- cbind(model = sModelNames, as.data.frame(t(do.call(rbind, lV))))
dfMean$evolution <- (dfMean[,3] - dfMean[,2]) / dfMean[,2]
write.table(dfMean, "tests/tmp/mean_execution_time.txt", row.names = FALSE, quote = F, sep = "\t")
write.table(dfMean, "tests/tmp/mean_execution_time.tsv", row.names = FALSE, quote = F, sep = "\t")
res <- testthat::test_file("tests/testthat/benchmarkRunModel.R")
dRes <- as.data.frame(res)
if (any(dRes[, "failed"] > 0) | any(dRes[, "error"])) {
......
......@@ -67,7 +67,7 @@ StoreTopicResults <- function(topic, package, path, run.dontrun = TRUE, run.dont
dev.off()
write.table(data.frame(topic = topic, time = end_time - start_time),
file.path(path, "timing.csv"),
file.path(path, "timing.tsv"),
row.names = FALSE, col.names = FALSE, quote = FALSE,
sep = "\t", append = TRUE)
......
df <- read.table("../tmp/mean_execution_time.txt", sep = "\t", header = T)
df <- read.table("../tmp/mean_execution_time.tsv", sep = "\t", header = T)
lapply(df$model, function(model) {
test_that(paste(model, ": RunModel should be as fast as CRAN version"), {
expect_lt(df$evolution[df$model == model], 1.1)
sel <- df$model == model
threshold <- max(0.2, -0.15 * df[sel, 2] + 1) # decrease from 1 at 0.1ms to 0.2 at 5.5ms
expect_lt(df$evolution[sel], threshold)
})
})
......@@ -33,7 +33,9 @@ CompareWithStable <- function(refVarFile, testDir, regIgnore) {
tmp_path <- file.path("../tmp", Sys.getenv("R_VERSION"));
if (dir.exists(file.path(tmp_path, "stable")) & dir.exists(file.path(tmp_path, "dev"))) {
refVarFiles <- list.files(file.path(tmp_path, "stable"), recursive = TRUE, full.names = TRUE)
refVarFiles <- list.files(path = file.path(tmp_path, "stable"),
pattern = "\\.rds$",
recursive = TRUE, full.names = TRUE)
regIgnoreFile <- "../../.regressionignore"
if (file.exists(regIgnoreFile)) {
message("Using .regressionignore file. The following variables are going to be skipped:")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment