Skip to content

Commit 5a3bf58

Browse files
committed
Permit perf test duration to be set, seconds, by environment variable 'PERF_DURATION_SEC'
1 parent ff55303 commit 5a3bf58

13 files changed

Lines changed: 18 additions & 13 deletions

tests/testthat/perf_tests/perf_rate.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ perf.reference.save <- function(perf.ref.name, rate, tolerance.lower, tolerance.
5757
.perf.reference <<- .perf.reference
5858
}
5959

60+
# Obtain performance test duration from PERF_DURATION_SEC environment variable, otherwise default.duration argument, otherwise "30".
61+
perf.testduration <- function(default.duration = 30) {
62+
base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = base::as.character(default.duration)))
63+
}
64+
6065
perf.reference.rate <- function(perf.ref.name) {
6166
if (is.null(.perf.reference))
6267
.load.pref()

tests/testthat/test-perf-conndisconn.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ disconnect.studies.dataset.cnsim()
2222

2323
# context("conndisconn::perf::simple0")
2424
test_that("simple connect - disconnect performance", {
25-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "120")) # defaults to 120 seconds
25+
.durationSec <- perf.testduration(120)
2626
.count <- 0
2727
.start.time <- Sys.time()
2828
.current.time <- .start.time

tests/testthat/test-perf-ds.abs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2121

2222
# context("ds.abs::perf:0")
2323
test_that("combine - performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

tests/testthat/test-perf-ds.asInteger.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("GENDER"))
2121

2222
# context("ds.asInteger::perf:0")
2323
test_that("combine - performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

tests/testthat/test-perf-ds.asList.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2121

2222
# context("ds.asList::perf:0")
2323
test_that("combine - performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

tests/testthat/test-perf-ds.asNumeric.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("GENDER"))
2121

2222
# context("ds.asNumeric::perf:0")
2323
test_that("combine - performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

tests/testthat/test-perf-ds.assign.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2121

2222
# context("ds.assign::perf::0")
2323
test_that("performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

tests/testthat/test-perf-ds.class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2121

2222
# context("ds.class::perf::combine:0")
2323
test_that("combine - performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

tests/testthat/test-perf-ds.colnames.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2121

2222
# context("ds.colnames::perf:0")
2323
test_that("combine - performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

tests/testthat/test-perf-ds.exists.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2121

2222
# context("ds.exists::perf::combine:0")
2323
test_that("combine - performance", {
24-
.durationSec <- base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = "30")) # defaults to 30 seconds
24+
.durationSec <- perf.testduration(30)
2525
.count <- 0
2626
.start.time <- Sys.time()
2727
.current.time <- .start.time

0 commit comments

Comments
 (0)