Skip to content

Commit 65b0844

Browse files
committed
test: add performance tests
1 parent f8d0ab4 commit 65b0844

File tree

7 files changed

+406
-0
lines changed

7 files changed

+406
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#-------------------------------------------------------------------------------
2+
#
3+
# This program and the accompanying materials
4+
# are made available under the terms of the GNU Public License v3.0.
5+
#
6+
# You should have received a copy of the GNU General Public License
7+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
8+
#-------------------------------------------------------------------------------
9+
10+
#
11+
# Set up
12+
#
13+
14+
# context("ds.asCharacter::perf::setup")
15+
connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
16+
17+
#
18+
# Tests
19+
#
20+
21+
# context("ds.asCharacter::perf:0")
22+
test_that("combine - performance", {
23+
.durationSec <- 30 # seconds
24+
.count <- 0
25+
.start.time <- Sys.time()
26+
.current.time <- .start.time
27+
28+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
29+
ds.asCharacter("D$LAB_TSC", newobj = "perf.newobj")
30+
31+
.count <- .count + 1
32+
.current.time <- Sys.time()
33+
}
34+
35+
.current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]])
36+
.reference.rate <- perf.reference.rate("ds.asCharacter::perf::0")
37+
if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) {
38+
print(paste("ds.asCharacter::perf::0 ", .current.rate, 0.5, 2.0))
39+
perf.reference.save("ds.asCharacter::perf::0", .current.rate, 0.5, 2.0)
40+
} else {
41+
print(paste("ds.asCharacter::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = ''))
42+
}
43+
44+
.reference.rate <- perf.reference.rate("ds.asCharacter::perf::0")
45+
.reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asCharacter::perf::0")
46+
.reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asCharacter::perf::0")
47+
48+
expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate")
49+
expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate")
50+
})
51+
52+
#
53+
# Done
54+
#
55+
56+
# context("ds.asCharacter::perf::shutdown")
57+
disconnect.studies.dataset.cnsim()
58+
# context("ds.asCharacter::perf::done")
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#-------------------------------------------------------------------------------
2+
#
3+
# This program and the accompanying materials
4+
# are made available under the terms of the GNU Public License v3.0.
5+
#
6+
# You should have received a copy of the GNU General Public License
7+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
8+
#-------------------------------------------------------------------------------
9+
10+
#
11+
# Set up
12+
#
13+
14+
# context("ds.asDataMatrix::perf::setup")
15+
connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
16+
17+
#
18+
# Tests
19+
#
20+
21+
# context("ds.asDataMatrix::perf:0")
22+
test_that("combine - performance", {
23+
.durationSec <- 30 # seconds
24+
.count <- 0
25+
.start.time <- Sys.time()
26+
.current.time <- .start.time
27+
28+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
29+
ds.asDataMatrix(x.name = "D", newobj = "perf.newobj")
30+
31+
.count <- .count + 1
32+
.current.time <- Sys.time()
33+
}
34+
35+
.current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]])
36+
.reference.rate <- perf.reference.rate("ds.asDataMatrix::perf::0")
37+
if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) {
38+
print(paste("ds.asDataMatrix::perf::0 ", .current.rate, 0.5, 2.0))
39+
perf.reference.save("ds.asDataMatrix::perf::0", .current.rate, 0.5, 2.0)
40+
} else {
41+
print(paste("ds.asDataMatrix::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = ''))
42+
}
43+
44+
.reference.rate <- perf.reference.rate("ds.asDataMatrix::perf::0")
45+
.reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asDataMatrix::perf::0")
46+
.reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asDataMatrix::perf::0")
47+
48+
expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate")
49+
expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate")
50+
})
51+
52+
#
53+
# Done
54+
#
55+
56+
# context("ds.asDataMatrix::perf::shutdown")
57+
disconnect.studies.dataset.cnsim()
58+
# context("ds.asDataMatrix::perf::done")
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#-------------------------------------------------------------------------------
2+
#
3+
# This program and the accompanying materials
4+
# are made available under the terms of the GNU Public License v3.0.
5+
#
6+
# You should have received a copy of the GNU General Public License
7+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
8+
#-------------------------------------------------------------------------------
9+
10+
#
11+
# Set up
12+
#
13+
14+
# context("ds.asLogical::perf::setup")
15+
connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
16+
17+
#
18+
# Tests
19+
#
20+
21+
# context("ds.asLogical::perf:0")
22+
test_that("combine - performance", {
23+
.durationSec <- 30 # seconds
24+
.count <- 0
25+
.start.time <- Sys.time()
26+
.current.time <- .start.time
27+
28+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
29+
ds.asLogical("D$LAB_TSC", newobj = "perf.newobj")
30+
31+
.count <- .count + 1
32+
.current.time <- Sys.time()
33+
}
34+
35+
.current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]])
36+
.reference.rate <- perf.reference.rate("ds.asLogical::perf::0")
37+
if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) {
38+
print(paste("ds.asLogical::perf::0 ", .current.rate, 0.5, 2.0))
39+
perf.reference.save("ds.asLogical::perf::0", .current.rate, 0.5, 2.0)
40+
} else {
41+
print(paste("ds.asLogical::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = ''))
42+
}
43+
44+
.reference.rate <- perf.reference.rate("ds.asLogical::perf::0")
45+
.reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asLogical::perf::0")
46+
.reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asLogical::perf::0")
47+
48+
expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate")
49+
expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate")
50+
})
51+
52+
#
53+
# Done
54+
#
55+
56+
# context("ds.asLogical::perf::shutdown")
57+
disconnect.studies.dataset.cnsim()
58+
# context("ds.asLogical::perf::done")
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#-------------------------------------------------------------------------------
2+
#
3+
# This program and the accompanying materials
4+
# are made available under the terms of the GNU Public License v3.0.
5+
#
6+
# You should have received a copy of the GNU General Public License
7+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
8+
#-------------------------------------------------------------------------------
9+
10+
#
11+
# Set up
12+
#
13+
14+
# context("ds.asMatrix::perf::setup")
15+
connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
16+
17+
#
18+
# Tests
19+
#
20+
21+
# context("ds.asMatrix::perf:0")
22+
test_that("combine - performance", {
23+
.durationSec <- 30 # seconds
24+
.count <- 0
25+
.start.time <- Sys.time()
26+
.current.time <- .start.time
27+
28+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
29+
ds.asMatrix(x.name = "D$LAB_TSC", newobj = "perf.newobj")
30+
31+
.count <- .count + 1
32+
.current.time <- Sys.time()
33+
}
34+
35+
.current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]])
36+
.reference.rate <- perf.reference.rate("ds.asMatrix::perf::0")
37+
if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) {
38+
print(paste("ds.asMatrix::perf::0 ", .current.rate, 0.5, 2.0))
39+
perf.reference.save("ds.asMatrix::perf::0", .current.rate, 0.5, 2.0)
40+
} else {
41+
print(paste("ds.asMatrix::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = ''))
42+
}
43+
44+
.reference.rate <- perf.reference.rate("ds.asMatrix::perf::0")
45+
.reference.tolerance.lower <- perf.reference.tolerance.lower("ds.asMatrix::perf::0")
46+
.reference.tolerance.upper <- perf.reference.tolerance.upper("ds.asMatrix::perf::0")
47+
48+
expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate")
49+
expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate")
50+
})
51+
52+
#
53+
# Done
54+
#
55+
56+
# context("ds.asMatrix::perf::shutdown")
57+
disconnect.studies.dataset.cnsim()
58+
# context("ds.asMatrix::perf::done")

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#-------------------------------------------------------------------------------
2+
#
3+
# This program and the accompanying materials
4+
# are made available under the terms of the GNU Public License v3.0.
5+
#
6+
# You should have received a copy of the GNU General Public License
7+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
8+
#-------------------------------------------------------------------------------
9+
10+
#
11+
# Set up
12+
#
13+
14+
# context("ds.exp::perf::setup")
15+
connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
16+
17+
#
18+
# Tests
19+
#
20+
21+
# context("ds.exp::perf:0")
22+
test_that("combine - performance", {
23+
.durationSec <- 30 # seconds
24+
.count <- 0
25+
.start.time <- Sys.time()
26+
.current.time <- .start.time
27+
28+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
29+
ds.exp("D$LAB_TSC", newobj = "perf.newobj")
30+
31+
.count <- .count + 1
32+
.current.time <- Sys.time()
33+
}
34+
35+
.current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]])
36+
.reference.rate <- perf.reference.rate("ds.exp::perf::0")
37+
if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) {
38+
print(paste("ds.exp::perf::0 ", .current.rate, 0.5, 2.0))
39+
perf.reference.save("ds.exp::perf::0", .current.rate, 0.5, 2.0)
40+
} else {
41+
print(paste("ds.exp::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = ''))
42+
}
43+
44+
.reference.rate <- perf.reference.rate("ds.exp::perf::0")
45+
.reference.tolerance.lower <- perf.reference.tolerance.lower("ds.exp::perf::0")
46+
.reference.tolerance.upper <- perf.reference.tolerance.upper("ds.exp::perf::0")
47+
48+
expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate")
49+
expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate")
50+
})
51+
52+
#
53+
# Done
54+
#
55+
56+
# context("ds.exp::perf::shutdown")
57+
disconnect.studies.dataset.cnsim()
58+
# context("ds.exp::perf::done")

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#-------------------------------------------------------------------------------
2+
#
3+
# This program and the accompanying materials
4+
# are made available under the terms of the GNU Public License v3.0.
5+
#
6+
# You should have received a copy of the GNU General Public License
7+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
8+
#-------------------------------------------------------------------------------
9+
10+
#
11+
# Set up
12+
#
13+
14+
# context("ds.log::perf::setup")
15+
connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
16+
17+
#
18+
# Tests
19+
#
20+
21+
# context("ds.log::perf:0")
22+
test_that("combine - performance", {
23+
.durationSec <- 30 # seconds
24+
.count <- 0
25+
.start.time <- Sys.time()
26+
.current.time <- .start.time
27+
28+
while (difftime(.current.time, .start.time, units = "secs")[[1]] < .durationSec) {
29+
ds.log("D$LAB_TSC", newobj = "perf.newobj")
30+
31+
.count <- .count + 1
32+
.current.time <- Sys.time()
33+
}
34+
35+
.current.rate <- .count / (difftime(.current.time, .start.time, units = "secs")[[1]])
36+
.reference.rate <- perf.reference.rate("ds.log::perf::0")
37+
if (any(length(.reference.rate) == 0) || any(is.null(.reference.rate))) {
38+
print(paste("ds.log::perf::0 ", .current.rate, 0.5, 2.0))
39+
perf.reference.save("ds.log::perf::0", .current.rate, 0.5, 2.0)
40+
} else {
41+
print(paste("ds.log::perf::0 ", format(.current.rate, digits = 8), ", ", format(100.0 * .current.rate / .reference.rate, digits = 4), "%", sep = ''))
42+
}
43+
44+
.reference.rate <- perf.reference.rate("ds.log::perf::0")
45+
.reference.tolerance.lower <- perf.reference.tolerance.lower("ds.log::perf::0")
46+
.reference.tolerance.upper <- perf.reference.tolerance.upper("ds.log::perf::0")
47+
48+
expect_gt(.current.rate, .reference.rate * .reference.tolerance.lower, label = "Observed rate", expected.label = "lower threshold on rate")
49+
expect_lt(.current.rate, .reference.rate * .reference.tolerance.upper, label = "Observed rate", expected.label = "upper threshold on rate")
50+
})
51+
52+
#
53+
# Done
54+
#
55+
56+
# context("ds.log::perf::shutdown")
57+
disconnect.studies.dataset.cnsim()
58+
# context("ds.log::perf::done")

0 commit comments

Comments
 (0)