colRowRanks_subset - HenrikBengtsson/matrixStats GitHub Wiki

matrixStats: Benchmark report


colRanks() and rowRanks() benchmarks on subsetted computation

This report benchmark the performance of colRanks() and rowRanks() on subsetted computation.

Data type "integer"

Data

> 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)

Results

10x10 integer matrix

> 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 3189675 170.4    5709258 305.0  5709258 305.0
Vcells 6391544  48.8   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3188374 170.3    5709258 305.0  5709258 305.0
Vcells 6387831  48.8   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.006350 0.0066575 0.0085987 0.0068765 0.0070935 0.172760
2 colRanks(X, rows, cols) 0.006669 0.0070055 0.0071930 0.0071355 0.0073320 0.009230
3 colRanks(X[rows, cols]) 0.007167 0.0075945 0.0078656 0.0077860 0.0079945 0.013184
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colRanks(X, rows, cols) 1.050236 1.052272 0.8365305 1.037664 1.033622 0.0534267
3 colRanks(X[rows, cols]) 1.128661 1.140743 0.9147438 1.132262 1.127018 0.0763140

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 0.002687 0.0030055 0.0031705 0.0031265 0.0032875 0.005524
2 rowRanks(X, cols, rows) 0.002975 0.0031885 0.0044617 0.0032855 0.0034170 0.114276
3 rowRanks(X[cols, rows]) 0.003320 0.0037140 0.0038791 0.0038280 0.0039815 0.005509
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanks(X, cols, rows) 1.107183 1.060888 1.407260 1.050856 1.039392 20.6871832
3 rowRanks(X[cols, rows]) 1.235579 1.235734 1.223493 1.224372 1.211103 0.9972846

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on integer+10x10 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 rowRanks_X_S 2.687 3.0055 3.17048 3.1265 3.2875 5.524
1 colRanks_X_S 6.350 6.6575 8.59867 6.8765 7.0935 172.760
expr min lq mean median uq max
2 rowRanks_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.00000
1 colRanks_X_S 2.36323 2.215106 2.712104 2.199424 2.157719 31.27444

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 integer matrix

> 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 3187051 170.3    5709258 305.0  5709258 305.0
Vcells 6056825  46.3   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3187042 170.3    5709258 305.0  5709258 305.0
Vcells 6061903  46.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.146100 0.1470375 0.1479697 0.1476670 0.148275 0.164900
2 colRanks(X, rows, cols) 0.152015 0.1531385 0.1540843 0.1537925 0.154551 0.162070
3 colRanks(X[rows, cols]) 0.154721 0.1560120 0.1575690 0.1566260 0.157623 0.214578
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 colRanks(X, rows, cols) 1.040486 1.041493 1.041323 1.041482 1.042327 0.9828381
3 colRanks(X[rows, cols]) 1.059008 1.061036 1.064874 1.060670 1.063045 1.3012614

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 0.132711 0.1344080 0.1353779 0.1348785 0.1354535 0.158191
2 rowRanks(X, cols, rows) 0.134021 0.1358705 0.1368152 0.1364685 0.1372090 0.151167
3 rowRanks(X[cols, rows]) 0.141178 0.1427820 0.1440559 0.1433960 0.1440355 0.182017
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanks(X, cols, rows) 1.009871 1.010881 1.010617 1.011788 1.012960 0.955598
3 rowRanks(X[cols, rows]) 1.063800 1.062303 1.064102 1.063149 1.063357 1.150615

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on integer+100x100 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 rowRanks_X_S 132.711 134.4080 135.3779 134.8785 135.4535 158.191
1 colRanks_X_S 146.100 147.0375 147.9697 147.6670 148.2750 164.900
expr min lq mean median uq max
2 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colRanks_X_S 1.100888 1.093964 1.093012 1.094815 1.094656 1.042411

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 integer matrix

> 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 3187804 170.3    5709258 305.0  5709258 305.0
Vcells 6060876  46.3   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3187795 170.3    5709258 305.0  5709258 305.0
Vcells 6065954  46.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.191569 0.1933455 0.1941410 0.1937770 0.194706 0.201388
2 colRanks(X, rows, cols) 0.195026 0.1968875 0.1984131 0.1974230 0.198151 0.257300
3 colRanks(X[rows, cols]) 0.200973 0.2023190 0.2033049 0.2028635 0.203853 0.212349
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanks(X, rows, cols) 1.018046 1.018320 1.022005 1.018815 1.017693 1.277633
3 colRanks(X[rows, cols]) 1.049089 1.046412 1.047202 1.046892 1.046979 1.054427

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 0.180956 0.1820075 0.1833657 0.1826700 0.1833715 0.219384
2 rowRanks(X, cols, rows) 0.183317 0.1844490 0.1854869 0.1851870 0.1856900 0.197945
3 rowRanks(X[cols, rows]) 0.190575 0.1917190 0.1927902 0.1924555 0.1932595 0.200437
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanks(X, cols, rows) 1.013047 1.013414 1.011568 1.013779 1.012644 0.9022764
3 rowRanks(X[cols, rows]) 1.053157 1.053358 1.051397 1.053569 1.053923 0.9136355

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on integer+1000x10 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 rowRanks_X_S 180.956 182.0075 183.3657 182.670 183.3715 219.384
1 colRanks_X_S 191.569 193.3455 194.1410 193.777 194.7060 201.388
expr min lq mean median uq max
2 rowRanks_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colRanks_X_S 1.05865 1.062294 1.058764 1.060804 1.061812 0.9179703

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 integer matrix

> 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 3188010 170.3    5709258 305.0  5709258 305.0
Vcells 6061730  46.3   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3188001 170.3    5709258 305.0  5709258 305.0
Vcells 6066808  46.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.082267 0.0838140 0.0850312 0.0848640 0.0859740 0.091612
2 colRanks(X, rows, cols) 0.089568 0.0924520 0.0940159 0.0932900 0.0940160 0.160850
3 colRanks(X[rows, cols]) 0.091614 0.0932985 0.0947615 0.0948925 0.0955365 0.102056
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanks(X, rows, cols) 1.088748 1.103061 1.105664 1.099288 1.093540 1.755774
3 colRanks(X[rows, cols]) 1.113618 1.113161 1.114433 1.118171 1.111225 1.114003

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 0.071534 0.0730685 0.0750661 0.0747220 0.0754385 0.114470
2 rowRanks(X, cols, rows) 0.075961 0.0782735 0.0794601 0.0792075 0.0799975 0.093830
3 rowRanks(X[cols, rows]) 0.079881 0.0814475 0.0825500 0.0823015 0.0833625 0.093299
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanks(X, cols, rows) 1.061887 1.071235 1.058536 1.060029 1.060433 0.8196907
3 rowRanks(X[cols, rows]) 1.116686 1.114673 1.099697 1.101436 1.105039 0.8150520

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on integer+10x1000 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 rowRanks_X_S 71.534 73.0685 75.06606 74.722 75.4385 114.470
1 colRanks_X_S 82.267 83.8140 85.03116 84.864 85.9740 91.612
expr min lq mean median uq max
2 rowRanks_X_S 1.000000 1.000000 1.000000 1.00000 1.000000 1.0000000
1 colRanks_X_S 1.150041 1.147061 1.132751 1.13573 1.139657 0.8003145

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 integer matrix

> 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 3188209 170.3    5709258 305.0  5709258 305.0
Vcells 6084391  46.5   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3188200 170.3    5709258 305.0  5709258 305.0
Vcells 6134469  46.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 1.411227 1.421110 1.492093 1.527478 1.536074 1.753078
2 colRanks(X, rows, cols) 1.460636 1.472684 1.633215 1.581341 1.592728 10.278399
3 colRanks(X[rows, cols]) 1.484481 1.496355 1.601260 1.653813 1.665463 1.830711
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanks(X, rows, cols) 1.035011 1.036292 1.094580 1.035262 1.036882 5.863059
3 colRanks(X[rows, cols]) 1.051908 1.052948 1.073164 1.082708 1.084234 1.044284

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 1.332971 1.362006 1.384078 1.368561 1.413801 1.445405
2 rowRanks(X, cols, rows) 1.344751 1.380868 1.402368 1.385862 1.432033 1.532496
3 rowRanks(X[cols, rows]) 1.424064 1.441168 1.471645 1.444830 1.496293 1.836529
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanks(X, cols, rows) 1.008837 1.013848 1.013214 1.012642 1.012896 1.060254
3 rowRanks(X[cols, rows]) 1.068338 1.058121 1.063267 1.055730 1.058348 1.270598

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on integer+100x1000 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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
2 rowRanks_X_S 1.332971 1.362006 1.384078 1.368561 1.413801 1.445405
1 colRanks_X_S 1.411227 1.421110 1.492093 1.527478 1.536074 1.753078
expr min lq mean median uq max
2 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colRanks_X_S 1.058708 1.043394 1.078041 1.116121 1.086485 1.212863

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 integer matrix

> 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 3188425 170.3    5709258 305.0  5709258 305.0
Vcells 6085174  46.5   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3188416 170.3    5709258 305.0  5709258 305.0
Vcells 6135252  46.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 1.853096 1.861617 1.913827 1.868316 1.969691 2.282829
2 colRanks(X, rows, cols) 1.870430 1.879618 1.928878 1.889724 1.989823 2.049448
3 colRanks(X[rows, cols]) 1.915856 1.924066 2.091811 1.931529 2.086304 10.843138
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 colRanks(X, rows, cols) 1.009354 1.009670 1.007864 1.011458 1.010220 0.8977668
3 colRanks(X[rows, cols]) 1.033868 1.033546 1.092999 1.033834 1.059203 4.7498687

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 1.786084 1.830661 1.845799 1.834907 1.873118 1.972461
2 rowRanks(X, cols, rows) 1.792278 1.842586 1.860069 1.846207 1.889986 2.008695
3 rowRanks(X[cols, rows]) 1.860194 1.907249 1.943382 1.916070 2.005546 2.294774
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanks(X, cols, rows) 1.003468 1.006514 1.007731 1.006158 1.009005 1.018370
3 rowRanks(X[cols, rows]) 1.041493 1.041836 1.052868 1.044232 1.070699 1.163407

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on integer+1000x100 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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
2 rowRanks_X_S 1.786084 1.830661 1.845799 1.834907 1.873118 1.972461
1 colRanks_X_S 1.853096 1.861617 1.913827 1.868316 1.969691 2.282829
expr min lq mean median uq max
2 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colRanks_X_S 1.037519 1.016909 1.036855 1.018207 1.051558 1.157351

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on integer+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Data type "double"

Data

> 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)

Results

10x10 double matrix

> 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 3188643 170.3    5709258 305.0  5709258 305.0
Vcells 6176271  47.2   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3188625 170.3    5709258 305.0  5709258 305.0
Vcells 6176434  47.2   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.006295 0.0065565 0.0074843 0.006799 0.0069920 0.073618
2 colRanks(X, rows, cols) 0.006528 0.0069690 0.0072039 0.007145 0.0073405 0.011847
3 colRanks(X[rows, cols]) 0.007289 0.0077305 0.0079796 0.007899 0.0080720 0.013689
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colRanks(X, rows, cols) 1.037014 1.062915 0.9625348 1.050890 1.049843 0.1609253
3 colRanks(X[rows, cols]) 1.157903 1.179059 1.0661787 1.161788 1.154462 0.1859464

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 0.002713 0.0030020 0.0032059 0.0030990 0.0032590 0.005540
2 rowRanks(X, cols, rows) 0.002975 0.0031710 0.0037138 0.0032460 0.0034215 0.043964
3 rowRanks(X[cols, rows]) 0.003426 0.0037305 0.0039460 0.0038625 0.0040475 0.006218
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanks(X, cols, rows) 1.096572 1.056296 1.158430 1.047435 1.049862 7.935740
3 rowRanks(X[cols, rows]) 1.262809 1.242672 1.230868 1.246370 1.241945 1.122383

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on double+10x10 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 rowRanks_X_S 2.713 3.0020 3.20590 3.099 3.259 5.540
1 colRanks_X_S 6.295 6.5565 7.48428 6.799 6.992 73.618
expr min lq mean median uq max
2 rowRanks_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.00000
1 colRanks_X_S 2.32031 2.184044 2.334533 2.193933 2.145443 13.28845

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 double matrix

> 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 3188844 170.4    5709258 305.0  5709258 305.0
Vcells 6182220  47.2   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3188835 170.4    5709258 305.0  5709258 305.0
Vcells 6192298  47.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.148067 0.1497760 0.1505854 0.1503645 0.1510290 0.157633
2 colRanks(X, rows, cols) 0.150516 0.1518635 0.1530059 0.1523510 0.1532895 0.175781
3 colRanks(X[rows, cols]) 0.165477 0.1666115 0.1684137 0.1672240 0.1677795 0.242017
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanks(X, rows, cols) 1.016540 1.013937 1.016074 1.013211 1.014967 1.115128
3 colRanks(X[rows, cols]) 1.117582 1.112405 1.118394 1.112124 1.110909 1.535319

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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
2 rowRanks(X, cols, rows) 0.141241 0.1425290 0.1433898 0.143155 0.1438515 0.149615
1 rowRanks_X_S 0.141344 0.1428305 0.1436151 0.143309 0.1438860 0.159763
3 rowRanks(X[cols, rows]) 0.149741 0.1513290 0.1529057 0.151880 0.1525175 0.218880
expr min lq mean median uq max
2 rowRanks(X, cols, rows) 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 rowRanks_X_S 1.000729 1.002115 1.001571 1.001076 1.000240 1.067827
3 rowRanks(X[cols, rows]) 1.060181 1.061742 1.066364 1.060948 1.060243 1.462955

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on double+100x100 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 rowRanks_X_S 141.344 142.8305 143.6151 143.3090 143.886 159.763
1 colRanks_X_S 148.067 149.7760 150.5854 150.3645 151.029 157.633
expr min lq mean median uq max
2 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colRanks_X_S 1.047565 1.048628 1.048535 1.049233 1.049643 0.9866678

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 double matrix

> 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 3189054 170.4    5709258 305.0  5709258 305.0
Vcells 6183638  47.2   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3189045 170.4    5709258 305.0  5709258 305.0
Vcells 6193716  47.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.207090 0.2092345 0.2107721 0.2100685 0.2111005 0.237037
2 colRanks(X, rows, cols) 0.209228 0.2105970 0.2123215 0.2113035 0.2121890 0.290789
3 colRanks(X[rows, cols]) 0.224139 0.2258135 0.2272842 0.2265125 0.2279600 0.240405
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanks(X, rows, cols) 1.010324 1.006512 1.007351 1.005879 1.005156 1.226766
3 colRanks(X[rows, cols]) 1.082326 1.079236 1.078341 1.078279 1.079865 1.014209

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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
2 rowRanks(X, cols, rows) 0.201641 0.2032225 0.2043059 0.2038650 0.2047990 0.226545
1 rowRanks_X_S 0.202491 0.2040215 0.2054759 0.2046010 0.2052390 0.261856
3 rowRanks(X[cols, rows]) 0.212711 0.2141600 0.2153143 0.2148135 0.2155685 0.231875
expr min lq mean median uq max
2 rowRanks(X, cols, rows) 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 rowRanks_X_S 1.004215 1.003932 1.005727 1.003610 1.002148 1.155868
3 rowRanks(X[cols, rows]) 1.054900 1.053820 1.053882 1.053705 1.052586 1.023527

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on double+1000x10 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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
2 rowRanks_X_S 202.491 204.0215 205.4759 204.6010 205.2390 261.856
1 colRanks_X_S 207.090 209.2345 210.7721 210.0685 211.1005 237.037
expr min lq mean median uq max
2 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colRanks_X_S 1.022712 1.025551 1.025775 1.026723 1.028559 0.9052189

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 double matrix

> 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 3189260 170.4    5709258 305.0  5709258 305.0
Vcells 6183775  47.2   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3189251 170.4    5709258 305.0  5709258 305.0
Vcells 6193853  47.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 0.082742 0.0842600 0.0857819 0.0855470 0.0868900 0.092634
2 colRanks(X, rows, cols) 0.085389 0.0873045 0.0888712 0.0878320 0.0884315 0.170394
3 colRanks(X[rows, cols]) 0.093323 0.0946875 0.0961895 0.0960605 0.0971350 0.105325
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanks(X, rows, cols) 1.031991 1.036132 1.036014 1.026711 1.017741 1.839433
3 colRanks(X[rows, cols]) 1.127879 1.123754 1.121326 1.122897 1.117908 1.137001

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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 rowRanks_X_S 0.075401 0.0769525 0.0786147 0.0781230 0.0791155 0.121670
2 rowRanks(X, cols, rows) 0.075996 0.0786775 0.0793945 0.0794095 0.0799530 0.086530
3 rowRanks(X[cols, rows]) 0.084051 0.0855795 0.0866718 0.0865045 0.0872585 0.102024
expr min lq mean median uq max
1 rowRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanks(X, cols, rows) 1.007891 1.022416 1.009919 1.016468 1.010586 0.7111860
3 rowRanks(X[cols, rows]) 1.114720 1.112108 1.102488 1.107286 1.102926 0.8385305

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on double+10x1000 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 rowRanks_X_S 75.401 76.9525 78.61471 78.123 79.1155 121.670
1 colRanks_X_S 82.742 84.2600 85.78187 85.547 86.8900 92.634
expr min lq mean median uq max
2 rowRanks_X_S 1.00000 1.000000 1.000000 1.00000 1.000000 1.0000000
1 colRanks_X_S 1.09736 1.094961 1.091168 1.09503 1.098268 0.7613545

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 double matrix

> 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 3189459 170.4    5709258 305.0  5709258 305.0
Vcells 6229227  47.6   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3189450 170.4    5709258 305.0  5709258 305.0
Vcells 6329305  48.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 1.477775 1.486052 1.543858 1.495405 1.600798 1.818087
2 colRanks(X, rows, cols) 1.497266 1.504472 1.552929 1.509940 1.620300 1.794940
3 colRanks(X[rows, cols]) 1.631080 1.640476 1.786297 1.651414 1.855884 7.422274
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 colRanks(X, rows, cols) 1.013189 1.012395 1.005876 1.009720 1.012182 0.9872685
3 colRanks(X[rows, cols]) 1.103740 1.103916 1.157035 1.104325 1.159349 4.0824636

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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
2 rowRanks(X, cols, rows) 1.474042 1.481378 1.506420 1.489056 1.531859 1.604075
1 rowRanks_X_S 1.464498 1.471701 1.502593 1.516644 1.526038 1.575866
3 rowRanks(X[cols, rows]) 1.559180 1.576128 1.639721 1.588039 1.708402 1.898545
expr min lq mean median uq max
2 rowRanks(X, cols, rows) 1.0000000 1.0000000 1.000000 1.000000 1.0000000 1.0000000
1 rowRanks_X_S 0.9935253 0.9934676 0.997460 1.018527 0.9961997 0.9824142
3 rowRanks(X[cols, rows]) 1.0577582 1.0639607 1.088489 1.066474 1.1152472 1.1835762

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on double+100x1000 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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 colRanks_X_S 1.477775 1.486052 1.543858 1.495405 1.600798 1.818087
2 rowRanks_X_S 1.464498 1.471701 1.502593 1.516644 1.526038 1.575866
expr min lq mean median uq max
1 colRanks_X_S 1.0000000 1.0000000 1.0000000 1.000000 1.0000000 1.0000000
2 rowRanks_X_S 0.9910155 0.9903429 0.9732721 1.014202 0.9532983 0.8667715

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 double matrix

> 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 3189675 170.4    5709258 305.0  5709258 305.0
Vcells 6229374  47.6   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanks_X_S = colRanks(X_S, na.rm = FALSE), `colRanks(X, rows, cols)` = colRanks(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanks(X[rows, cols])` = colRanks(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 3189666 170.4    5709258 305.0  5709258 305.0
Vcells 6329452  48.3   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanks_X_S = rowRanks(X_S, na.rm = FALSE), `rowRanks(X, cols, rows)` = rowRanks(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanks(X[cols, rows])` = rowRanks(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(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 colRanks_X_S 2.013273 2.073523 2.094985 2.078577 2.092253 2.226805
2 colRanks(X, rows, cols) 2.022983 2.080008 2.121242 2.085494 2.167508 2.623835
3 colRanks(X[rows, cols]) 2.086775 2.142638 2.246980 2.147093 2.157801 8.187684
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanks(X, rows, cols) 1.004823 1.003127 1.012533 1.003328 1.035969 1.178296
3 colRanks(X[rows, cols]) 1.036509 1.033332 1.072552 1.032963 1.031329 3.676875

Table: Benchmarking of rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(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
2 rowRanks(X, cols, rows) 2.023542 2.079500 2.104647 2.095444 2.126408 2.257241
1 rowRanks_X_S 2.030250 2.085611 2.113265 2.100188 2.133288 2.416232
3 rowRanks(X[cols, rows]) 2.123181 2.177160 2.234303 2.183795 2.315200 2.404712
expr min lq mean median uq max
2 rowRanks(X, cols, rows) 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 rowRanks_X_S 1.003315 1.002938 1.004095 1.002264 1.003235 1.070436
3 rowRanks(X[cols, rows]) 1.049240 1.046963 1.061605 1.042164 1.088785 1.065332

Figure: Benchmarking of colRanks_X_S(), colRanks(X, rows, cols)() and colRanks(X[rows, cols])() on double+1000x100 data as well as rowRanks_X_S(), rowRanks(X, cols, rows)() and rowRanks(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks_X_S() and rowRanks_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
1 colRanks_X_S 2.013273 2.073523 2.094985 2.078577 2.092253 2.226805
2 rowRanks_X_S 2.030250 2.085611 2.113265 2.100188 2.133288 2.416232
expr min lq mean median uq max
1 colRanks_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanks_X_S 1.008433 1.005829 1.008725 1.010398 1.019613 1.085067

Figure: Benchmarking of colRanks_X_S() and rowRanks_X_S() on double+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Appendix

Session information

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 27.3 secs.

Reproducibility

To reproduce this report, do:

html <- matrixStats:::benchmark('colRowRanks_subset')

Copyright Dongcan Jiang. Last updated on 2019-09-10 20:51:58 (-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>
⚠️ **GitHub.com Fallback** ⚠️