Skip to content

Commit 6a1b21f

Browse files
Merge pull request #468 from StuartWheater/v6.3.6-dev_feat-perf-support
Permit individual perf test duration to be set
2 parents 1aa5c13 + e75797b commit 6a1b21f

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

tests/testthat/perf_tests/perf_rate.R

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

48+
# Obtain performance test duration from PERF_DURATION_SEC environment variable, otherwise default.duration argument, otherwise "30".
49+
perf.testduration <- function(default.duration = 30) {
50+
base::as.integer(base::Sys.getenv("PERF_DURATION_SEC", unset = base::as.character(default.duration)))
51+
}
52+
4853
perf.reference.rate <- function(perf.ref.name) {
4954
if (is.null(.perf.reference))
5055
.load.pref()

tests/testthat/test-perf-meanDS.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test_that("numeric meanDS - performance", {
3030

3131
input <- c(0.0, 1.0, 2.0, 3.0, 4.0)
3232

33-
.durationSec <- 30 # seconds
33+
.durationSec <- perf.testduration(30)
3434
.count <- 0
3535
.start.time <- Sys.time()
3636
.current.time <- .start.time
@@ -65,7 +65,7 @@ test_that("numeric meanDS, with NA - performance", {
6565

6666
input <- c(0.0, NA, 2.0, NA, 4.0)
6767

68-
.durationSec <- 30 # seconds
68+
.durationSec <- perf.testduration(30)
6969
.count <- 0
7070
.start.time <- Sys.time()
7171
.current.time <- .start.time

tests/testthat/test-perf-varDS.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test_that("numeric varDS - performance", {
3030

3131
input <- c(0.0, 1.0, 2.0, 3.0, 4.0)
3232

33-
.durationSec <- 30 # seconds
33+
.durationSec <- perf.testduration(30)
3434
.count <- 0
3535
.start.time <- Sys.time()
3636
.current.time <- .start.time
@@ -65,7 +65,7 @@ test_that("numeric varDS, with NA - performance", {
6565

6666
input <- c(0.0, NA, 2.0, NA, 4.0)
6767

68-
.durationSec <- 30 # seconds
68+
.durationSec <- perf.testduration(30)
6969
.count <- 0
7070
.start.time <- Sys.time()
7171
.current.time <- .start.time

0 commit comments

Comments
 (0)