Skip to content

Commit 9b301ce

Browse files
Merge pull request #344 from StuartWheater/v6.3.1-dev
Initial performance test
2 parents 2f44186 + f30a8bf commit 9b301ce

2 files changed

Lines changed: 138 additions & 0 deletions

File tree

tests/testthat/test-perf-meanDS.R

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2024 Arjuna Technologies, Newcastle upon Tyne. All rights reserved.
3+
#
4+
# This program and the accompanying materials
5+
# are made available under the terms of the GNU Public License v3.0.
6+
#
7+
# You should have received a copy of the GNU General Public License
8+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
9+
#-------------------------------------------------------------------------------
10+
11+
#
12+
# Set up
13+
#
14+
15+
context("meanDS::perf::setup")
16+
17+
set.standard.disclosure.settings()
18+
19+
#
20+
# Tests
21+
#
22+
23+
context("meanDS::perf::numeric")
24+
test_that("numeric meanDS - performance", {
25+
input <- c(0.0, 1.0, 2.0, 3.0, 4.0)
26+
27+
.durationSec <- 30 # seconds
28+
.count <- 0
29+
.start.time <- Sys.time()
30+
.current.time <- .start.time
31+
32+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
33+
meanDS(input)
34+
35+
.count <- .count + 1
36+
.current.time <- Sys.time()
37+
}
38+
expect_true(TRUE)
39+
40+
print(paste("meanDS::perf::number::0:", format(.count / (difftime(.current.time, .start.time, units = "secs")[[1]]), digits = 8)))
41+
})
42+
43+
context("meanDS::perf::numeric with NA")
44+
test_that("numeric meanDS, with NA - performance", {
45+
input <- c(0.0, NA, 2.0, NA, 4.0)
46+
47+
.durationSec <- 30 # seconds
48+
.count <- 0
49+
.start.time <- Sys.time()
50+
.current.time <- .start.time
51+
52+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
53+
meanDS(input)
54+
55+
.count <- .count + 1
56+
.current.time <- Sys.time()
57+
}
58+
expect_true(TRUE)
59+
60+
print(paste("meanDS::perf::numberAndNA::0:", format(.count / (difftime(.current.time, .start.time, units = "secs")[[1]]), digits = 8)))
61+
})
62+
63+
#
64+
# Done
65+
#
66+
67+
context("meanDS::perf::shutdown")
68+
69+
context("meanDS::perf::done")

tests/testthat/test-perf-varDS.R

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2024 Arjuna Technologies, Newcastle upon Tyne. All rights reserved.
3+
#
4+
# This program and the accompanying materials
5+
# are made available under the terms of the GNU Public License v3.0.
6+
#
7+
# You should have received a copy of the GNU General Public License
8+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
9+
#-------------------------------------------------------------------------------
10+
11+
#
12+
# Set up
13+
#
14+
15+
context("varDS::perf::setup")
16+
17+
set.standard.disclosure.settings()
18+
19+
#
20+
# Tests
21+
#
22+
23+
context("varDS::perf::numeric")
24+
test_that("numeric varDS - performance", {
25+
input <- c(0.0, 1.0, 2.0, 3.0, 4.0)
26+
27+
.durationSec <- 30 # seconds
28+
.count <- 0
29+
.start.time <- Sys.time()
30+
.current.time <- .start.time
31+
32+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
33+
varDS(input)
34+
35+
.count <- .count + 1
36+
.current.time <- Sys.time()
37+
}
38+
expect_true(TRUE)
39+
40+
print(paste("varDS::perf::number::0:", format(.count / (difftime(.current.time, .start.time, units = "secs")[[1]]), digits = 8)))
41+
})
42+
43+
context("varDS::perf::numeric with NA")
44+
test_that("numeric varDS, with NA - performance", {
45+
input <- c(0.0, NA, 2.0, NA, 4.0)
46+
47+
.durationSec <- 30 # seconds
48+
.count <- 0
49+
.start.time <- Sys.time()
50+
.current.time <- .start.time
51+
52+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
53+
varDS(input)
54+
55+
.count <- .count + 1
56+
.current.time <- Sys.time()
57+
}
58+
expect_true(TRUE)
59+
60+
print(paste("varDS::perf::numberAndNA::0:", format(.count / (difftime(.current.time, .start.time, units = "secs")[[1]]), digits = 8)))
61+
})
62+
63+
#
64+
# Done
65+
#
66+
67+
context("varDS::perf::shutdown")
68+
69+
context("varDS::perf::done")

0 commit comments

Comments
 (0)