colRowRanges_subset - HenrikBengtsson/matrixStats GitHub Wiki

matrixStats: Benchmark report


colRanges() and rowRanges() benchmarks on subsetted computation

This report benchmark the performance of colRanges() and rowRanges() 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 3182203 170.0    5709258 305.0  5709258 305.0
Vcells 6337876  48.4   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3180566 169.9    5709258 305.0  5709258 305.0
Vcells 6333239  48.4   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.001090 0.0011260 0.0021293 0.0011460 0.0012185 0.090667
2 colRanges(X, rows, cols) 0.001244 0.0012865 0.0013782 0.0013170 0.0014005 0.003072
3 colRanges(X[rows, cols]) 0.001613 0.0017385 0.0020145 0.0019135 0.0020670 0.006976
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colRanges(X, rows, cols) 1.141284 1.142540 0.6472483 1.149215 1.149364 0.0338822
3 colRanges(X[rows, cols]) 1.479817 1.543961 0.9461221 1.669721 1.696348 0.0769409

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.001092 0.0011170 0.0012227 0.001139 0.0012520 0.003600
2 rowRanges(X, cols, rows) 0.001252 0.0012860 0.0023361 0.001307 0.0014580 0.097008
3 rowRanges(X[cols, rows]) 0.001591 0.0016915 0.0019833 0.001850 0.0020055 0.005741
expr min lq mean median uq max
1 rowRanges_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.14652 1.151298 1.910544 1.147498 1.164537 26.946667
3 rowRanges(X[cols, rows]) 1.45696 1.514324 1.622015 1.624232 1.601837 1.594722

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 rowRanges_X_S 1.092 1.117 1.22272 1.139 1.2520 3.600
1 colRanges_X_S 1.090 1.126 2.12926 1.146 1.2185 90.667
expr min lq mean median uq max
2 rowRanges_X_S 1.0000000 1.000000 1.000000 1.000000 1.0000000 1.00000
1 colRanges_X_S 0.9981685 1.008057 1.741413 1.006146 0.9732428 25.18528

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3179169 169.8    5709258 305.0  5709258 305.0
Vcells 6002108  45.8   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3179160 169.8    5709258 305.0  5709258 305.0
Vcells 6007186  45.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.010970 0.0113120 0.0115660 0.0115065 0.0117045 0.015767
2 colRanges(X, rows, cols) 0.013220 0.0137885 0.0141243 0.0140740 0.0143185 0.017172
3 colRanges(X[rows, cols]) 0.018492 0.0189510 0.0196369 0.0191305 0.0193970 0.051053
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.205105 1.218927 1.221185 1.223135 1.223333 1.089110
3 colRanges(X[rows, cols]) 1.685688 1.675301 1.697803 1.662582 1.657226 3.237965

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.010728 0.0110495 0.0113798 0.0112150 0.0114895 0.015325
2 rowRanges(X, cols, rows) 0.011691 0.0122685 0.0125412 0.0124550 0.0126930 0.015745
3 rowRanges(X[cols, rows]) 0.018101 0.0186580 0.0195912 0.0189275 0.0192535 0.064185
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.089765 1.110322 1.102051 1.110566 1.104748 1.027406
3 rowRanges(X[cols, rows]) 1.687267 1.688583 1.721567 1.687695 1.675747 4.188255

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 rowRanges_X_S 10.728 11.0495 11.37985 11.2150 11.4895 15.325
1 colRanges_X_S 10.970 11.3120 11.56605 11.5065 11.7045 15.767
expr min lq mean median uq max
2 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colRanges_X_S 1.022558 1.023757 1.016362 1.025992 1.018713 1.028842

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3179918 169.9    5709258 305.0  5709258 305.0
Vcells 6006174  45.9   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3179909 169.9    5709258 305.0  5709258 305.0
Vcells 6011252  45.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.007932 0.0080580 0.0082060 0.008130 0.0082630 0.011447
2 colRanges(X, rows, cols) 0.009957 0.0100750 0.0105154 0.010216 0.0104325 0.036373
3 colRanges(X[rows, cols]) 0.015409 0.0156155 0.0160531 0.015756 0.0159915 0.025840
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.255295 1.250310 1.281421 1.256581 1.262556 3.177514
3 colRanges(X[rows, cols]) 1.942637 1.937888 1.956255 1.938007 1.935314 2.257360

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.008930 0.009213 0.0098794 0.0092835 0.0093795 0.031482
2 rowRanges(X, cols, rows) 0.010282 0.010612 0.0118905 0.0107725 0.0109395 0.036882
3 rowRanges(X[cols, rows]) 0.017307 0.017879 0.0192193 0.0180830 0.0183120 0.053687
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.151400 1.151851 1.203561 1.160392 1.166320 1.171527
3 rowRanges(X[cols, rows]) 1.938074 1.940627 1.945382 1.947865 1.952343 1.705324

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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
1 colRanges_X_S 7.932 8.058 8.20602 8.1300 8.2630 11.447
2 rowRanges_X_S 8.930 9.213 9.87943 9.2835 9.3795 31.482
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.00000 1.00000
2 rowRanges_X_S 1.125819 1.143336 1.203925 1.141882 1.13512 2.75024

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3180124 169.9    5709258 305.0  5709258 305.0
Vcells 6007031  45.9   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3180115 169.9    5709258 305.0  5709258 305.0
Vcells 6012109  45.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.021663 0.0226605 0.0233331 0.0232045 0.0236995 0.029203
2 colRanges(X, rows, cols) 0.027995 0.0293930 0.0305225 0.0302155 0.0308265 0.067626
3 colRanges(X[rows, cols]) 0.030748 0.0316230 0.0327176 0.0320380 0.0328885 0.049906
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.00000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.292296 1.297103 1.308122 1.30214 1.300724 2.315721
3 colRanges(X[rows, cols]) 1.419379 1.395512 1.402196 1.38068 1.387730 1.708934

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.021073 0.0220045 0.0226350 0.0224385 0.0229385 0.038305
2 rowRanges(X, cols, rows) 0.022086 0.0238320 0.0242872 0.0243370 0.0247630 0.028424
3 rowRanges(X[cols, rows]) 0.029005 0.0297885 0.0303246 0.0301120 0.0305035 0.042943
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanges(X, cols, rows) 1.048071 1.083051 1.072995 1.084609 1.079539 0.7420441
3 rowRanges(X[cols, rows]) 1.376406 1.353746 1.339722 1.341979 1.329795 1.1210808

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 rowRanges_X_S 21.073 22.0045 22.63495 22.4385 22.9385 38.305
1 colRanges_X_S 21.663 22.6605 23.33309 23.2045 23.6995 29.203
expr min lq mean median uq max
2 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colRanges_X_S 1.027998 1.029812 1.030844 1.034138 1.033176 0.7623809

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3180323 169.9    5709258 305.0  5709258 305.0
Vcells 6029691  46.1   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3180314 169.9    5709258 305.0  5709258 305.0
Vcells 6079769  46.4   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.106644 0.1073510 0.1080100 0.107762 0.1081135 0.115837
2 colRanges(X, rows, cols) 0.133348 0.1340055 0.1356224 0.134500 0.1351675 0.220734
3 colRanges(X[rows, cols]) 0.178587 0.1796025 0.1813233 0.180086 0.1811260 0.202905
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.250403 1.248293 1.255646 1.248121 1.250237 1.905557
3 colRanges(X[rows, cols]) 1.674609 1.673040 1.678763 1.671146 1.675332 1.751642

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.104170 0.1051490 0.1060804 0.1055540 0.1059540 0.127620
2 rowRanges(X, cols, rows) 0.116271 0.1175575 0.1183745 0.1180615 0.1184810 0.134772
3 rowRanges(X[cols, rows]) 0.167494 0.1690150 0.1712729 0.1696345 0.1706875 0.227266
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.116166 1.118009 1.115894 1.118494 1.118231 1.056041
3 rowRanges(X[cols, rows]) 1.607891 1.607386 1.614558 1.607087 1.610958 1.780802

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 rowRanges_X_S 104.170 105.149 106.0804 105.554 105.9540 127.620
1 colRanges_X_S 106.644 107.351 108.0100 107.762 108.1135 115.837
expr min lq mean median uq max
2 rowRanges_X_S 1.00000 1.000000 1.00000 1.000000 1.000000 1.0000000
1 colRanges_X_S 1.02375 1.020942 1.01819 1.020918 1.020382 0.9076712

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3180539 169.9    5709258 305.0  5709258 305.0
Vcells 6030482  46.1   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3180530 169.9    5709258 305.0  5709258 305.0
Vcells 6080560  46.4   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.070667 0.0712605 0.0719798 0.0714400 0.0716405 0.096485
2 colRanges(X, rows, cols) 0.085166 0.0858685 0.0868319 0.0861460 0.0868310 0.108069
3 colRanges(X[rows, cols]) 0.134336 0.1348045 0.1371886 0.1351895 0.1365980 0.212129
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.00000
2 colRanges(X, rows, cols) 1.205174 1.204994 1.206338 1.205851 1.212038 1.12006
3 colRanges(X[rows, cols]) 1.900972 1.891714 1.905933 1.892350 1.906715 2.19857

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.076880 0.0773960 0.0778467 0.0777270 0.0779475 0.083768
2 rowRanges(X, cols, rows) 0.090642 0.0913865 0.0918813 0.0915955 0.0918210 0.099784
3 rowRanges(X[cols, rows]) 0.148250 0.1490800 0.1511589 0.1494645 0.1503420 0.229534
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.179006 1.180765 1.180285 1.178426 1.177985 1.191195
3 rowRanges(X[cols, rows]) 1.928330 1.926198 1.941751 1.922942 1.928760 2.740116

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 colRanges_X_S 70.667 71.2605 71.97976 71.440 71.6405 96.485
2 rowRanges_X_S 76.880 77.3960 77.84667 77.727 77.9475 83.768
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.0000 1.000000 1.000000 1.000000 1.0000000
2 rowRanges_X_S 1.087919 1.0861 1.081508 1.088004 1.088037 0.8681971

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3180757 169.9    5709258 305.0  5709258 305.0
Vcells 6121590  46.8   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3180739 169.9    5709258 305.0  5709258 305.0
Vcells 6121753  46.8   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.001065 0.0010980 0.0012882 0.0011225 0.0011985 0.013261
2 colRanges(X, rows, cols) 0.001233 0.0013100 0.0013996 0.0013340 0.0014160 0.004094
3 colRanges(X[rows, cols]) 0.001685 0.0018745 0.0020288 0.0019555 0.0020425 0.006468
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 colRanges(X, rows, cols) 1.157747 1.193078 1.086496 1.188419 1.181477 0.3087248
3 colRanges(X[rows, cols]) 1.582160 1.707195 1.574964 1.742093 1.704214 0.4877460

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.001091 0.0011390 0.0012359 0.0011695 0.0012730 0.002975
2 rowRanges(X, cols, rows) 0.001228 0.0012930 0.0015560 0.0013200 0.0014225 0.020242
3 rowRanges(X[cols, rows]) 0.001614 0.0017785 0.0019172 0.0018580 0.0019470 0.004203
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.125573 1.135206 1.258993 1.128688 1.117439 6.804034
3 rowRanges(X[cols, rows]) 1.479377 1.561457 1.551240 1.588713 1.529458 1.412773

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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
1 colRanges_X_S 1.065 1.098 1.28815 1.1225 1.1985 13.261
2 rowRanges_X_S 1.091 1.139 1.23594 1.1695 1.2730 2.975
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanges_X_S 1.024413 1.037341 0.959469 1.041871 1.062161 0.2243421

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3180958 169.9    5709258 305.0  5709258 305.0
Vcells 6127545  46.8   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3180949 169.9    5709258 305.0  5709258 305.0
Vcells 6137623  46.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.008210 0.0085490 0.0087703 0.0087240 0.0088610 0.013393
2 colRanges(X, rows, cols) 0.011324 0.0117125 0.0122276 0.0118640 0.0122115 0.029017
3 colRanges(X[rows, cols]) 0.023852 0.0243985 0.0249778 0.0245675 0.0247210 0.058056
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.379293 1.370043 1.394198 1.359927 1.378118 2.166580
3 colRanges(X[rows, cols]) 2.905238 2.853960 2.847980 2.816082 2.789866 4.334802

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.011820 0.0122955 0.0125662 0.012508 0.0126795 0.016145
2 rowRanges(X, cols, rows) 0.011972 0.0125130 0.0129063 0.012770 0.0129870 0.017451
3 rowRanges(X[cols, rows]) 0.019413 0.0199120 0.0208002 0.020126 0.0203820 0.080707
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.012860 1.017689 1.027063 1.020947 1.024252 1.080892
3 rowRanges(X[cols, rows]) 1.642386 1.619454 1.655252 1.609050 1.607477 4.998885

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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
1 colRanges_X_S 8.21 8.5490 8.77034 8.724 8.8610 13.393
2 rowRanges_X_S 11.82 12.2955 12.56618 12.508 12.6795 16.145
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.00000
2 rowRanges_X_S 1.439708 1.438238 1.432804 1.433746 1.430933 1.20548

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3181168 169.9    5709258 305.0  5709258 305.0
Vcells 6128962  46.8   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3181159 169.9    5709258 305.0  5709258 305.0
Vcells 6139040  46.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.006826 0.006998 0.0071366 0.0070695 0.0071950 0.010718
2 colRanges(X, rows, cols) 0.009641 0.009910 0.0102917 0.0100005 0.0101285 0.035653
3 colRanges(X[rows, cols]) 0.022677 0.022804 0.0229688 0.0229135 0.0229975 0.027748
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.412394 1.416119 1.442101 1.414598 1.407714 3.326460
3 colRanges(X[rows, cols]) 3.322151 3.258645 3.218454 3.241177 3.196317 2.588916

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.010227 0.0103790 0.0107991 0.0104625 0.010551 0.040578
2 rowRanges(X, cols, rows) 0.011592 0.0119025 0.0124504 0.0122210 0.012439 0.038032
3 rowRanges(X[cols, rows]) 0.019229 0.0197995 0.0200289 0.0199785 0.020164 0.026432
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanges(X, cols, rows) 1.133470 1.146787 1.152904 1.168076 1.178940 0.9372566
3 rowRanges(X[cols, rows]) 1.880219 1.907650 1.854678 1.909534 1.911099 0.6513875

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 colRanges_X_S 6.826 6.998 7.13660 7.0695 7.195 10.718
2 rowRanges_X_S 10.227 10.379 10.79914 10.4625 10.551 40.578
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges_X_S 1.498242 1.483138 1.513205 1.479949 1.466435 3.785967

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3181365 170.0    5709258 305.0  5709258 305.0
Vcells 6129084  46.8   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3181365 170.0    5709258 305.0  5709258 305.0
Vcells 6139177  46.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.018690 0.020484 0.0215774 0.0216015 0.0221880 0.031057
2 colRanges(X, rows, cols) 0.025960 0.028222 0.0295472 0.0291165 0.0299860 0.065011
3 colRanges(X[rows, cols]) 0.028935 0.030216 0.0311852 0.0312600 0.0319745 0.037561
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.388978 1.377758 1.369363 1.347892 1.351451 2.093280
3 colRanges(X[rows, cols]) 1.548154 1.475102 1.445275 1.447122 1.441072 1.209421

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.021389 0.0226125 0.0231756 0.0230595 0.0232190 0.042653
2 rowRanges(X, cols, rows) 0.022330 0.0242145 0.0249002 0.0248250 0.0254350 0.030853
3 rowRanges(X[cols, rows]) 0.030004 0.0308745 0.0313960 0.0311435 0.0314465 0.045963
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowRanges(X, cols, rows) 1.043995 1.070846 1.074416 1.076563 1.095439 0.7233489
3 rowRanges(X[cols, rows]) 1.402777 1.365373 1.354704 1.350571 1.354343 1.0776030

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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
1 colRanges_X_S 18.690 20.4840 21.57735 21.6015 22.188 31.057
2 rowRanges_X_S 21.389 22.6125 23.17556 23.0595 23.219 42.653
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.00000 1.000000 1.000000 1.000000 1.000000
2 rowRanges_X_S 1.144409 1.10391 1.074069 1.067495 1.046467 1.373378

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3181573 170.0    5709258 305.0  5709258 305.0
Vcells 6174555  47.2   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3181564 170.0    5709258 305.0  5709258 305.0
Vcells 6274633  47.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.100562 0.1012370 0.1019546 0.101508 0.1019375 0.115033
2 colRanges(X, rows, cols) 0.134218 0.1350955 0.1364043 0.135314 0.1356110 0.233219
3 colRanges(X[rows, cols]) 0.248367 0.2496655 0.2543097 0.250348 0.2521670 0.365943
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.00000
2 colRanges(X, rows, cols) 1.334679 1.334448 1.337892 1.333038 1.330335 2.02741
3 colRanges(X[rows, cols]) 2.469790 2.466149 2.494343 2.466288 2.473741 3.18120

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.116119 0.116875 0.1177092 0.1171680 0.117585 0.138375
2 rowRanges(X, cols, rows) 0.135232 0.136289 0.1374557 0.1365975 0.137253 0.179292
3 rowRanges(X[cols, rows]) 0.186056 0.187095 0.1905034 0.1879500 0.189161 0.304286
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.164598 1.166109 1.167757 1.165826 1.167266 1.295697
3 rowRanges(X[cols, rows]) 1.602287 1.600813 1.618424 1.604107 1.608717 2.198996

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 colRanges_X_S 100.562 101.237 101.9546 101.508 101.9375 115.033
2 rowRanges_X_S 116.119 116.875 117.7092 117.168 117.5850 138.375
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges_X_S 1.154701 1.154469 1.154526 1.154274 1.153501 1.202916

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 3181789 170.0    5709258 305.0  5709258 305.0
Vcells 6174702  47.2   22343563 170.5 56666022 432.4
> colStats <- microbenchmark(colRanges_X_S = colRanges(X_S, na.rm = FALSE), `colRanges(X, rows, cols)` = colRanges(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colRanges(X[rows, cols])` = colRanges(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 3181780 170.0    5709258 305.0  5709258 305.0
Vcells 6274780  47.9   22343563 170.5 56666022 432.4
> rowStats <- microbenchmark(rowRanges_X_S = rowRanges(X_S, na.rm = FALSE), `rowRanges(X, cols, rows)` = rowRanges(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowRanges(X[cols, rows])` = rowRanges(X[cols, rows], 
+     na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges_X_S(), colRanges(X, rows, cols)() and colRanges(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 colRanges_X_S 0.060877 0.0611645 0.0616153 0.061334 0.0616005 0.070619
2 colRanges(X, rows, cols) 0.085854 0.0863455 0.0866055 0.086484 0.0866800 0.090331
3 colRanges(X[rows, cols]) 0.130192 0.1312110 0.1345383 0.131964 0.1327190 0.265479
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colRanges(X, rows, cols) 1.410286 1.411693 1.405585 1.410050 1.407131 1.279132
3 colRanges(X[rows, cols]) 2.138607 2.145215 2.183523 2.151564 2.154512 3.759314

Table: Benchmarking of rowRanges_X_S(), rowRanges(X, cols, rows)() and rowRanges(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 rowRanges_X_S 0.089140 0.0896180 0.0900077 0.0898030 0.0900340 0.095609
2 rowRanges(X, cols, rows) 0.106737 0.1072765 0.1078168 0.1076055 0.1078565 0.118149
3 rowRanges(X[cols, rows]) 0.163829 0.1649710 0.1681752 0.1655475 0.1667735 0.306344
expr min lq mean median uq max
1 rowRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges(X, cols, rows) 1.197409 1.197042 1.197862 1.198239 1.197953 1.235752
3 rowRanges(X[cols, rows]) 1.837884 1.840824 1.868453 1.843452 1.852339 3.204134

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

Table: Benchmarking of colRanges_X_S() and rowRanges_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 colRanges_X_S 60.877 61.1645 61.61526 61.334 61.6005 70.619
2 rowRanges_X_S 89.140 89.6180 90.00770 89.803 90.0340 95.609
expr min lq mean median uq max
1 colRanges_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowRanges_X_S 1.464264 1.465196 1.460802 1.464163 1.461579 1.353871

Figure: Benchmarking of colRanges_X_S() and rowRanges_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 23.23 secs.

Reproducibility

To reproduce this report, do:

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

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