|
| 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") |
0 commit comments