colRowMads_subset - HenrikBengtsson/matrixStats GitHub Wiki
matrixStats: Benchmark report
This report benchmark the performance of colMads() and rowMads() on subsetted computation.
> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100,
+ +100), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)> X <- data[["10x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127712 167.1 5709258 305.0 5709258 305.0
Vcells 5944525 45.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126871 167.0 5709258 305.0 5709258 305.0
Vcells 5942293 45.4 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.001618 | 0.001650 | 0.0030489 | 0.0016855 | 0.0017835 | 0.133118 |
| 2 | colMads(X, rows, cols) | 0.001788 | 0.001845 | 0.0019660 | 0.0018920 | 0.0019995 | 0.004344 |
| 3 | colMads(X[rows, cols]) | 0.002188 | 0.002389 | 0.0025937 | 0.0025155 | 0.0026230 | 0.006317 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | colMads(X, rows, cols) | 1.105068 | 1.118182 | 0.6448183 | 1.122516 | 1.121110 | 0.0326327 |
| 3 | colMads(X[rows, cols]) | 1.352287 | 1.447879 | 0.8507063 | 1.492436 | 1.470704 | 0.0474541 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on integer+10x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.001594 | 0.0016560 | 0.0017765 | 0.0016845 | 0.0018295 | 0.004182 |
| 2 | rowMads(X, cols, rows) | 0.001782 | 0.0018410 | 0.0034641 | 0.0019110 | 0.0020485 | 0.152137 |
| 3 | rowMads(X[cols, rows]) | 0.002171 | 0.0023605 | 0.0026019 | 0.0024825 | 0.0026305 | 0.007368 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads(X, cols, rows) | 1.117942 | 1.111715 | 1.949963 | 1.134461 | 1.119705 | 36.379005 |
| 3 | rowMads(X[cols, rows]) | 1.361982 | 1.425423 | 1.464599 | 1.473731 | 1.437825 | 1.761836 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+10x10 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.594 | 1.656 | 1.77650 | 1.6845 | 1.8295 | 4.182 |
| 1 | colMads_X_S | 1.618 | 1.650 | 3.04889 | 1.6855 | 1.7835 | 133.118 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 | 1.00000 |
| 1 | colMads_X_S | 1.015057 | 0.9963768 | 1.716234 | 1.000594 | 0.9748565 | 31.83118 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3125581 167.0 5709258 305.0 5709258 305.0
Vcells 5610824 42.9 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3125575 167.0 5709258 305.0 5709258 305.0
Vcells 5615907 42.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.124557 | 0.1253345 | 0.1259331 | 0.125692 | 0.1261295 | 0.130745 |
| 2 | colMads(X, rows, cols) | 0.125732 | 0.1274145 | 0.1280266 | 0.127867 | 0.1283200 | 0.136184 |
| 3 | colMads(X[rows, cols]) | 0.133008 | 0.1335405 | 0.1346972 | 0.134001 | 0.1345355 | 0.185799 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads(X, rows, cols) | 1.009433 | 1.016596 | 1.016624 | 1.017304 | 1.017367 | 1.041600 |
| 3 | colMads(X[rows, cols]) | 1.067848 | 1.065473 | 1.069593 | 1.066106 | 1.066646 | 1.421079 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on integer+100x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.124224 | 0.1251330 | 0.1258091 | 0.1256310 | 0.1260185 | 0.133772 |
| 2 | rowMads(X, cols, rows) | 0.126334 | 0.1271960 | 0.1278689 | 0.1277505 | 0.1283000 | 0.132051 |
| 3 | rowMads(X[cols, rows]) | 0.132569 | 0.1335745 | 0.1347110 | 0.1338725 | 0.1342685 | 0.181574 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads(X, cols, rows) | 1.016985 | 1.016487 | 1.016372 | 1.016871 | 1.018104 | 0.9871348 |
| 3 | rowMads(X[cols, rows]) | 1.067177 | 1.067460 | 1.070757 | 1.065601 | 1.065467 | 1.3573394 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+100x100 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+100x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 124.224 | 125.1330 | 125.8091 | 125.631 | 126.0185 | 133.772 |
| 1 | colMads_X_S | 124.557 | 125.3345 | 125.9331 | 125.692 | 126.1295 | 130.745 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 1 | colMads_X_S | 1.002681 | 1.00161 | 1.000986 | 1.000485 | 1.000881 | 0.9773719 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126332 167.0 5709258 305.0 5709258 305.0
Vcells 5614885 42.9 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126323 167.0 5709258 305.0 5709258 305.0
Vcells 5619963 42.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.081427 | 0.0826875 | 0.0832570 | 0.0830020 | 0.0833390 | 0.100612 |
| 2 | colMads(X, rows, cols) | 0.083962 | 0.0847270 | 0.0854519 | 0.0850420 | 0.0853190 | 0.126803 |
| 3 | colMads(X[rows, cols]) | 0.089906 | 0.0907615 | 0.0916832 | 0.0911845 | 0.0917125 | 0.106254 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads(X, rows, cols) | 1.031132 | 1.024665 | 1.026362 | 1.024578 | 1.023758 | 1.260317 |
| 3 | colMads(X[rows, cols]) | 1.104130 | 1.097645 | 1.101206 | 1.098582 | 1.100475 | 1.056077 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on integer+1000x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.081849 | 0.0825785 | 0.0836888 | 0.0829080 | 0.0833035 | 0.118436 |
| 2 | rowMads(X, cols, rows) | 0.084582 | 0.0850780 | 0.0855695 | 0.0852765 | 0.0857000 | 0.096658 |
| 3 | rowMads(X[cols, rows]) | 0.091102 | 0.0920475 | 0.0925392 | 0.0924060 | 0.0925715 | 0.102606 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads(X, cols, rows) | 1.033391 | 1.030268 | 1.022472 | 1.028568 | 1.028768 | 0.8161201 |
| 3 | rowMads(X[cols, rows]) | 1.113050 | 1.114667 | 1.105754 | 1.114561 | 1.111256 | 0.8663413 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+1000x10 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+1000x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 81.849 | 82.5785 | 83.68883 | 82.908 | 83.3035 | 118.436 |
| 1 | colMads_X_S | 81.427 | 82.6875 | 83.25705 | 83.002 | 83.3390 | 100.612 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.0000000 | 1.00000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
| 1 | colMads_X_S | 0.9948442 | 1.00132 | 0.9948406 | 1.001134 | 1.000426 | 0.8495052 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["10x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126535 167.0 5709258 305.0 5709258 305.0
Vcells 5615703 42.9 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126529 167.0 5709258 305.0 5709258 305.0
Vcells 5620786 42.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.074979 | 0.076251 | 0.0785998 | 0.0776810 | 0.0789350 | 0.144374 |
| 2 | colMads(X, rows, cols) | 0.079670 | 0.081699 | 0.0835705 | 0.0828720 | 0.0837255 | 0.132708 |
| 3 | colMads(X[rows, cols]) | 0.083884 | 0.085756 | 0.0876781 | 0.0871725 | 0.0884730 | 0.119358 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | colMads(X, rows, cols) | 1.062564 | 1.071448 | 1.06324 | 1.066825 | 1.060689 | 0.9191960 |
| 3 | colMads(X[rows, cols]) | 1.118767 | 1.124654 | 1.11550 | 1.122186 | 1.120834 | 0.8267278 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on integer+10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.075136 | 0.0763025 | 0.0781011 | 0.0775200 | 0.0785300 | 0.121054 |
| 2 | rowMads(X, cols, rows) | 0.078360 | 0.0810635 | 0.0822967 | 0.0825625 | 0.0833075 | 0.087298 |
| 3 | rowMads(X[cols, rows]) | 0.082860 | 0.0845020 | 0.0859525 | 0.0856260 | 0.0866880 | 0.102774 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads(X, cols, rows) | 1.042909 | 1.062396 | 1.053720 | 1.065048 | 1.060837 | 0.7211492 |
| 3 | rowMads(X[cols, rows]) | 1.102800 | 1.107460 | 1.100528 | 1.104567 | 1.103884 | 0.8489930 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+10x1000 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 75.136 | 76.3025 | 78.10114 | 77.520 | 78.530 | 121.054 |
| 1 | colMads_X_S | 74.979 | 76.2510 | 78.59984 | 77.681 | 78.935 | 144.374 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.0000000 | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 1 | colMads_X_S | 0.9979105 | 0.9993251 | 1.006385 | 1.002077 | 1.005157 | 1.192641 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126734 167.0 5709258 305.0 5709258 305.0
Vcells 5638357 43.1 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126728 167.0 5709258 305.0 5709258 305.0
Vcells 5688440 43.4 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.266993 | 1.270186 | 1.294061 | 1.271557 | 1.274584 | 1.750929 |
| 2 | colMads(X, rows, cols) | 1.284522 | 1.287359 | 1.331201 | 1.289322 | 1.298381 | 1.795537 |
| 3 | colMads(X[rows, cols]) | 1.340125 | 1.344108 | 1.382902 | 1.346618 | 1.359126 | 2.112093 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads(X, rows, cols) | 1.013835 | 1.013520 | 1.028701 | 1.013971 | 1.018670 | 1.025477 |
| 3 | colMads(X[rows, cols]) | 1.057721 | 1.058198 | 1.068653 | 1.059030 | 1.066329 | 1.206270 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on integer+100x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.269649 | 1.271853 | 1.276187 | 1.273303 | 1.275263 | 1.361940 |
| 2 | rowMads(X, cols, rows) | 1.300770 | 1.302888 | 1.306933 | 1.304312 | 1.307311 | 1.372135 |
| 3 | rowMads(X[cols, rows]) | 1.334043 | 1.336432 | 1.345289 | 1.338763 | 1.341876 | 1.669967 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads(X, cols, rows) | 1.024512 | 1.024401 | 1.024092 | 1.024353 | 1.025130 | 1.007486 |
| 3 | rowMads(X[cols, rows]) | 1.050718 | 1.050776 | 1.054147 | 1.051410 | 1.052235 | 1.226168 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+100x1000 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+100x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.266993 | 1.270186 | 1.294061 | 1.271557 | 1.274584 | 1.750929 |
| 2 | rowMads_X_S | 1.269649 | 1.271853 | 1.276187 | 1.273303 | 1.275263 | 1.361940 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads_X_S | 1.002096 | 1.001313 | 0.9861873 | 1.001373 | 1.000533 | 0.7778385 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126950 167.0 5709258 305.0 5709258 305.0
Vcells 5639132 43.1 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3126944 167.0 5709258 305.0 5709258 305.0
Vcells 5689215 43.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.946344 | 0.9490525 | 0.9556377 | 0.9504085 | 0.952523 | 1.170666 |
| 2 | colMads(X, rows, cols) | 0.958893 | 0.9625085 | 0.9665988 | 0.9634775 | 0.965221 | 1.054095 |
| 3 | colMads(X[rows, cols]) | 1.009027 | 1.0123290 | 1.0228459 | 1.0142980 | 1.016363 | 1.735138 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | colMads(X, rows, cols) | 1.013260 | 1.014178 | 1.011470 | 1.013751 | 1.013331 | 0.9004233 |
| 3 | colMads(X[rows, cols]) | 1.066237 | 1.066673 | 1.070328 | 1.067223 | 1.067022 | 1.4821802 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on integer+1000x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.954634 | 0.9583080 | 0.9617993 | 0.9604665 | 0.9628435 | 0.990129 |
| 2 | rowMads(X, cols, rows) | 0.980087 | 0.9830515 | 0.9857112 | 0.9844675 | 0.9868645 | 1.043447 |
| 3 | rowMads(X[cols, rows]) | 1.028572 | 1.0316400 | 1.0438749 | 1.0347785 | 1.0389705 | 1.586369 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads(X, cols, rows) | 1.026663 | 1.025820 | 1.024862 | 1.024989 | 1.024948 | 1.053850 |
| 3 | rowMads(X[cols, rows]) | 1.077452 | 1.076522 | 1.085336 | 1.077371 | 1.079065 | 1.602184 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on integer+1000x100 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+1000x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 946.344 | 949.0525 | 955.6377 | 950.4085 | 952.5230 | 1170.666 |
| 2 | rowMads_X_S | 954.634 | 958.3080 | 961.7993 | 960.4665 | 962.8435 | 990.129 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads_X_S | 1.00876 | 1.009752 | 1.006448 | 1.010583 | 1.010835 | 0.8457827 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on integer+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100,
+ +100), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)> X <- data[["10x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127168 167.1 5709258 305.0 5709258 305.0
Vcells 5730221 43.8 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127153 167.1 5709258 305.0 5709258 305.0
Vcells 5730389 43.8 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.002072 | 0.0021300 | 0.0024325 | 0.00220 | 0.0022990 | 0.020894 |
| 2 | colMads(X, rows, cols) | 0.002278 | 0.0023440 | 0.0024972 | 0.00242 | 0.0025555 | 0.005687 |
| 3 | colMads(X[rows, cols]) | 0.002730 | 0.0029925 | 0.0031582 | 0.00307 | 0.0031870 | 0.007702 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | colMads(X, rows, cols) | 1.099421 | 1.100469 | 1.026619 | 1.100000 | 1.111570 | 0.2721834 |
| 3 | colMads(X[rows, cols]) | 1.317568 | 1.404930 | 1.298357 | 1.395455 | 1.386255 | 0.3686226 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on double+10x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.002087 | 0.0021295 | 0.0022628 | 0.0021765 | 0.0023210 | 0.005127 |
| 2 | rowMads(X, cols, rows) | 0.002264 | 0.0023235 | 0.0027862 | 0.0023875 | 0.0025560 | 0.034763 |
| 3 | rowMads(X[cols, rows]) | 0.002641 | 0.0029090 | 0.0031310 | 0.0030215 | 0.0031795 | 0.009112 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads(X, cols, rows) | 1.084811 | 1.091101 | 1.231295 | 1.096945 | 1.101249 | 6.780378 |
| 3 | rowMads(X[cols, rows]) | 1.265453 | 1.366048 | 1.383718 | 1.388238 | 1.369884 | 1.777258 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+10x10 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on double+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 2.087 | 2.1295 | 2.26278 | 2.1765 | 2.321 | 5.127 |
| 1 | colMads_X_S | 2.072 | 2.1300 | 2.43249 | 2.2000 | 2.299 | 20.894 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 |
| 1 | colMads_X_S | 0.9928126 | 1.000235 | 1.075001 | 1.010797 | 0.9905213 | 4.075288 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127370 167.1 5709258 305.0 5709258 305.0
Vcells 5736165 43.8 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127364 167.1 5709258 305.0 5709258 305.0
Vcells 5746248 43.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.175992 | 0.1771095 | 0.1790892 | 0.1775235 | 0.1781175 | 0.208572 |
| 2 | colMads(X, rows, cols) | 0.178243 | 0.1791985 | 0.1820410 | 0.1796175 | 0.1808025 | 0.237350 |
| 3 | colMads(X[rows, cols]) | 0.192604 | 0.1929905 | 0.1983176 | 0.1936020 | 0.1967005 | 0.279061 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads(X, rows, cols) | 1.012790 | 1.011795 | 1.016482 | 1.011796 | 1.015074 | 1.137976 |
| 3 | colMads(X[rows, cols]) | 1.094391 | 1.089668 | 1.107368 | 1.090571 | 1.104330 | 1.337960 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on double+100x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.176137 | 0.1768865 | 0.1776898 | 0.177294 | 0.1777170 | 0.190034 |
| 2 | rowMads(X, cols, rows) | 0.178403 | 0.1790985 | 0.1799678 | 0.179428 | 0.1799115 | 0.194887 |
| 3 | rowMads(X[cols, rows]) | 0.184098 | 0.1848915 | 0.1863995 | 0.185234 | 0.1856800 | 0.235587 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads(X, cols, rows) | 1.012865 | 1.012505 | 1.012820 | 1.012037 | 1.012348 | 1.025537 |
| 3 | rowMads(X[cols, rows]) | 1.045198 | 1.045255 | 1.049017 | 1.044784 | 1.044807 | 1.239710 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+100x100 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on double+100x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 176.137 | 176.8865 | 177.6898 | 177.2940 | 177.7170 | 190.034 |
| 1 | colMads_X_S | 175.992 | 177.1095 | 179.0892 | 177.5235 | 178.1175 | 208.572 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 1 | colMads_X_S | 0.9991768 | 1.001261 | 1.007876 | 1.001294 | 1.002254 | 1.097551 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127579 167.1 5709258 305.0 5709258 305.0
Vcells 5737570 43.8 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127573 167.1 5709258 305.0 5709258 305.0
Vcells 5747653 43.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.149481 | 0.151056 | 0.1538088 | 0.1515275 | 0.1556925 | 0.172223 |
| 2 | colMads(X, rows, cols) | 0.151703 | 0.153301 | 0.1569379 | 0.1566535 | 0.1574605 | 0.211940 |
| 3 | colMads(X[rows, cols]) | 0.166276 | 0.167164 | 0.1699902 | 0.1692095 | 0.1713810 | 0.216658 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads(X, rows, cols) | 1.014865 | 1.014862 | 1.020344 | 1.033829 | 1.011356 | 1.230614 |
| 3 | colMads(X[rows, cols]) | 1.112355 | 1.106636 | 1.105204 | 1.116692 | 1.100766 | 1.258009 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on double+1000x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.150658 | 0.1518865 | 0.1558518 | 0.152485 | 0.1556505 | 0.268986 |
| 2 | rowMads(X, cols, rows) | 0.152853 | 0.1537925 | 0.1555724 | 0.154502 | 0.1574575 | 0.173438 |
| 3 | rowMads(X[cols, rows]) | 0.160257 | 0.1613410 | 0.1646386 | 0.161975 | 0.1652725 | 0.265232 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads(X, cols, rows) | 1.014569 | 1.012549 | 0.9982073 | 1.013227 | 1.011609 | 0.6447845 |
| 3 | rowMads(X[cols, rows]) | 1.063714 | 1.062247 | 1.0563792 | 1.062236 | 1.061818 | 0.9860439 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+1000x10 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on double+1000x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 149.481 | 151.0560 | 153.8088 | 151.5275 | 155.6925 | 172.223 |
| 2 | rowMads_X_S | 150.658 | 151.8865 | 155.8518 | 152.4850 | 155.6505 | 268.986 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 |
| 2 | rowMads_X_S | 1.007874 | 1.005498 | 1.013283 | 1.006319 | 0.9997302 | 1.561847 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["10x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127785 167.1 5709258 305.0 5709258 305.0
Vcells 5737707 43.8 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127779 167.1 5709258 305.0 5709258 305.0
Vcells 5747790 43.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 0.134798 | 0.1359665 | 0.1382682 | 0.136553 | 0.137308 | 0.294956 |
| 2 | colMads(X, rows, cols) | 0.137468 | 0.1390495 | 0.1403244 | 0.139813 | 0.140279 | 0.194123 |
| 3 | colMads(X[rows, cols]) | 0.144962 | 0.1457125 | 0.1465781 | 0.146069 | 0.146608 | 0.167936 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | colMads(X, rows, cols) | 1.019807 | 1.022675 | 1.014871 | 1.023874 | 1.021637 | 0.6581422 |
| 3 | colMads(X[rows, cols]) | 1.075402 | 1.071679 | 1.060100 | 1.069687 | 1.067731 | 0.5693595 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on double+10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 0.134364 | 0.1358465 | 0.1368990 | 0.1363815 | 0.1369665 | 0.176040 |
| 2 | rowMads(X, cols, rows) | 0.137478 | 0.1390235 | 0.1398765 | 0.1399440 | 0.1404265 | 0.142730 |
| 3 | rowMads(X[cols, rows]) | 0.143316 | 0.1441095 | 0.1450114 | 0.1446385 | 0.1452310 | 0.163589 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads(X, cols, rows) | 1.023176 | 1.023387 | 1.021749 | 1.026122 | 1.025262 | 0.8107816 |
| 3 | rowMads(X[cols, rows]) | 1.066625 | 1.060826 | 1.059259 | 1.060543 | 1.060340 | 0.9292718 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+10x1000 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on double+10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 134.364 | 135.8465 | 136.8990 | 136.3815 | 136.9665 | 176.040 |
| 1 | colMads_X_S | 134.798 | 135.9665 | 138.2682 | 136.5530 | 137.3080 | 294.956 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 1 | colMads_X_S | 1.00323 | 1.000883 | 1.010001 | 1.001257 | 1.002493 | 1.675506 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127984 167.1 5709258 305.0 5709258 305.0
Vcells 5783145 44.2 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3127978 167.1 5709258 305.0 5709258 305.0
Vcells 5883228 44.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.787152 | 1.789640 | 1.797647 | 1.792476 | 1.795505 | 1.902440 |
| 2 | colMads(X, rows, cols) | 1.801339 | 1.805511 | 1.816375 | 1.808668 | 1.813373 | 1.951420 |
| 3 | colMads(X[rows, cols]) | 1.933494 | 1.939144 | 1.951791 | 1.941461 | 1.945466 | 2.535541 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads(X, rows, cols) | 1.007938 | 1.008868 | 1.010418 | 1.009033 | 1.009951 | 1.025746 |
| 3 | colMads(X[rows, cols]) | 1.081886 | 1.083538 | 1.085748 | 1.083117 | 1.083520 | 1.332784 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on double+100x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.789684 | 1.792204 | 1.806411 | 1.793496 | 1.795767 | 2.251923 |
| 2 | rowMads(X, cols, rows) | 1.824163 | 1.828401 | 1.832759 | 1.830094 | 1.832475 | 1.921615 |
| 3 | rowMads(X[cols, rows]) | 1.861569 | 1.873429 | 1.886224 | 1.876369 | 1.882099 | 2.245709 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads(X, cols, rows) | 1.019265 | 1.020197 | 1.014586 | 1.020406 | 1.020442 | 0.8533218 |
| 3 | rowMads(X[cols, rows]) | 1.040166 | 1.045322 | 1.044183 | 1.046207 | 1.048075 | 0.9972406 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+100x1000 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on double+100x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.787152 | 1.789640 | 1.797647 | 1.792476 | 1.795505 | 1.902440 |
| 2 | rowMads_X_S | 1.789684 | 1.792204 | 1.806411 | 1.793496 | 1.795767 | 2.251923 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads_X_S | 1.001417 | 1.001432 | 1.004875 | 1.000569 | 1.000146 | 1.183703 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3128200 167.1 5709258 305.0 5709258 305.0
Vcells 5783292 44.2 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads_X_S = colMads(X_S, na.rm = FALSE), `colMads(X, rows, cols)` = colMads(X,
+ rows = rows, cols = cols, na.rm = FALSE), `colMads(X[rows, cols])` = colMads(X[rows, cols], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3128194 167.1 5709258 305.0 5709258 305.0
Vcells 5883375 44.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads_X_S = rowMads(X_S, na.rm = FALSE), `rowMads(X, cols, rows)` = rowMads(X,
+ rows = cols, cols = rows, na.rm = FALSE), `rowMads(X[cols, rows])` = rowMads(X[cols, rows], na.rm = FALSE),
+ unit = "ms")Table: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.626832 | 1.640737 | 1.741858 | 1.668980 | 1.722789 | 2.576678 |
| 2 | colMads(X, rows, cols) | 1.640423 | 1.670357 | 1.824553 | 1.703631 | 1.914551 | 2.833088 |
| 3 | colMads(X[rows, cols]) | 1.693803 | 1.725707 | 1.898453 | 1.774982 | 1.913741 | 2.805058 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads(X, rows, cols) | 1.008354 | 1.018053 | 1.047475 | 1.020762 | 1.111309 | 1.099512 |
| 3 | colMads(X[rows, cols]) | 1.041167 | 1.051788 | 1.089901 | 1.063514 | 1.110839 | 1.088634 |
Table: Benchmarking of rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on double+1000x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.637332 | 1.642232 | 1.665525 | 1.649308 | 1.677045 | 1.938316 |
| 2 | rowMads(X, cols, rows) | 1.671836 | 1.676944 | 1.701091 | 1.684074 | 1.717871 | 1.993383 |
| 3 | rowMads(X[cols, rows]) | 1.718952 | 1.728274 | 1.748624 | 1.736360 | 1.758601 | 2.062640 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads_X_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
| 2 | rowMads(X, cols, rows) | 1.021073 | 1.021137 | 1.021355 | 1.021079 | 1.024344 | 1.02841 |
| 3 | rowMads(X[cols, rows]) | 1.049849 | 1.052393 | 1.049894 | 1.052781 | 1.048631 | 1.06414 |
Figure: Benchmarking of colMads_X_S(), colMads(X, rows, cols)() and colMads(X[rows, cols])() on double+1000x100 data as well as rowMads_X_S(), rowMads(X, cols, rows)() and rowMads(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads_X_S() and rowMads_X_S() on double+1000x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.637332 | 1.642232 | 1.665525 | 1.649308 | 1.677045 | 1.938316 |
| 1 | colMads_X_S | 1.626832 | 1.640737 | 1.741858 | 1.668980 | 1.722789 | 2.576678 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads_X_S | 1.0000000 | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 1 | colMads_X_S | 0.9935871 | 0.9990897 | 1.045832 | 1.011927 | 1.027277 | 1.329338 |
Figure: Benchmarking of colMads_X_S() and rowMads_X_S() on double+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

R version 3.6.1 Patched (2019-08-27 r77078)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] microbenchmark_1.4-6 matrixStats_0.55.0-9000 ggplot2_3.2.1
[4] knitr_1.24 R.devices_2.16.0 R.utils_2.9.0
[7] R.oo_1.22.0 R.methodsS3_1.7.1 history_0.0.0-9002
loaded via a namespace (and not attached):
[1] Biobase_2.45.0 bit64_0.9-7 splines_3.6.1
[4] network_1.15 assertthat_0.2.1 highr_0.8
[7] stats4_3.6.1 blob_1.2.0 robustbase_0.93-5
[10] pillar_1.4.2 RSQLite_2.1.2 backports_1.1.4
[13] lattice_0.20-38 glue_1.3.1 digest_0.6.20
[16] colorspace_1.4-1 sandwich_2.5-1 Matrix_1.2-17
[19] XML_3.98-1.20 lpSolve_5.6.13.3 pkgconfig_2.0.2
[22] genefilter_1.66.0 purrr_0.3.2 ergm_3.10.4
[25] xtable_1.8-4 mvtnorm_1.0-11 scales_1.0.0
[28] tibble_2.1.3 annotate_1.62.0 IRanges_2.18.2
[31] TH.data_1.0-10 withr_2.1.2 BiocGenerics_0.30.0
[34] lazyeval_0.2.2 mime_0.7 survival_2.44-1.1
[37] magrittr_1.5 crayon_1.3.4 statnet.common_4.3.0
[40] memoise_1.1.0 laeken_0.5.0 R.cache_0.13.0
[43] MASS_7.3-51.4 R.rsp_0.43.1 tools_3.6.1
[46] multcomp_1.4-10 S4Vectors_0.22.1 trust_0.1-7
[49] munsell_0.5.0 AnnotationDbi_1.46.1 compiler_3.6.1
[52] rlang_0.4.0 grid_3.6.1 RCurl_1.95-4.12
[55] cwhmisc_6.6 rappdirs_0.3.1 labeling_0.3
[58] bitops_1.0-6 base64enc_0.1-3 boot_1.3-23
[61] gtable_0.3.0 codetools_0.2-16 DBI_1.0.0
[64] markdown_1.1 R6_2.4.0 zoo_1.8-6
[67] dplyr_0.8.3 bit_1.1-14 zeallot_0.1.0
[70] parallel_3.6.1 Rcpp_1.0.2 vctrs_0.2.0
[73] DEoptimR_1.0-8 tidyselect_0.2.5 xfun_0.9
[76] coda_0.19-3 Total processing time was 26.41 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colRowMads_subset')Copyright Dongcan Jiang. Last updated on 2019-09-10 20:41:51 (-0700 UTC). Powered by RSP.
<script> var link = document.createElement('link'); link.rel = 'icon'; link.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAA21BMVEUAAAAAAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8BAf4CAv0DA/wdHeIeHuEfH+AgIN8hId4lJdomJtknJ9g+PsE/P8BAQL9yco10dIt1dYp3d4h4eIeVlWqWlmmXl2iYmGeZmWabm2Tn5xjo6Bfp6Rb39wj4+Af//wA2M9hbAAAASXRSTlMAAQIJCgsMJSYnKD4/QGRlZmhpamtsbautrrCxuru8y8zN5ebn6Pn6+///////////////////////////////////////////LsUNcQAAAS9JREFUOI29k21XgkAQhVcFytdSMqMETU26UVqGmpaiFbL//xc1cAhhwVNf6n5i5z67M2dmYOyfJZUqlVLhkKucG7cgmUZTybDz6g0iDeq51PUr37Ds2cy2/C9NeES5puDjxuUk1xnToZsg8pfA3avHQ3lLIi7iWRrkv/OYtkScxBIMgDee0ALoyxHQBJ68JLCjOtQIMIANF7QG9G9fNnHvisCHBVMKgSJgiz7nE+AoBKrAPA3MgepvgR9TSCasrCKH0eB1wBGBFdCO+nAGjMVGPcQb5bd6mQRegN6+1axOs9nGfYcCtfi4NQosdtH7dB+txFIpXQqN1p9B/asRHToyS0jRgpV7nk4nwcq1BJ+x3Gl/v7S9Wmpp/aGquum7w3ZDyrADFYrl8vHBH+ev9AUASW1dmU4h4wAAAABJRU5ErkJggg==" document.getElementsByTagName('head')[0].appendChild(link); </script>