colRowMins_subset - HenrikBengtsson/matrixStats GitHub Wiki

matrixStats: Benchmark report


colMins() and rowMins() benchmarks on subsetted computation

This report benchmark the performance of colMins() and rowMins() 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 3152524 168.4    5709258 305.0  5709258 305.0
Vcells 6113243  46.7   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3150887 168.3    5709258 305.0  5709258 305.0
Vcells 6108606  46.7   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.001007 0.001044 0.0020731 0.0010675 0.0011325 0.096081
2 colMins(X, rows, cols) 0.001189 0.001262 0.0013410 0.0012940 0.0013335 0.002630
3 colMins(X[rows, cols]) 0.001526 0.001639 0.0019254 0.0018040 0.0019150 0.008220
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colMins(X, rows, cols) 1.180735 1.208812 0.6468608 1.212178 1.177483 0.0273727
3 colMins(X[rows, cols]) 1.515392 1.569923 0.9287354 1.689930 1.690949 0.0855528

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.001025 0.0010660 0.0012008 0.0010950 0.0012100 0.004037
2 rowMins(X, cols, rows) 0.001188 0.0012305 0.0023439 0.0012585 0.0013410 0.102176
3 rowMins(X[cols, rows]) 0.001515 0.0016665 0.0019821 0.0017975 0.0019125 0.010462
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins(X, cols, rows) 1.159024 1.154315 1.951917 1.149315 1.108264 25.309884
3 rowMins(X[cols, rows]) 1.478049 1.563321 1.650592 1.641552 1.580579 2.591528

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

Table: Benchmarking of colMins_X_S() and rowMins_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
1 colMins_X_S 1.007 1.044 2.07312 1.0675 1.1325 96.081
2 rowMins_X_S 1.025 1.066 1.20083 1.0950 1.2100 4.037
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 rowMins_X_S 1.017875 1.021073 0.5792381 1.025761 1.068433 0.0420166

Figure: Benchmarking of colMins_X_S() and rowMins_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 3149483 168.3    5709258 305.0  5709258 305.0
Vcells 5777465  44.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3149477 168.3    5709258 305.0  5709258 305.0
Vcells 5782548  44.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.008103 0.0084380 0.0087821 0.0085820 0.0087010 0.025702
2 colMins(X, rows, cols) 0.010012 0.0105080 0.0108916 0.0106665 0.0108375 0.029379
3 colMins(X[rows, cols]) 0.015774 0.0161075 0.0173583 0.0163135 0.0165875 0.060722
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.235592 1.245319 1.240214 1.242892 1.245546 1.143063
3 colMins(X[rows, cols]) 1.946686 1.908924 1.976561 1.900897 1.906390 2.362540

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.008160 0.0087060 0.0091645 0.0089405 0.0090770 0.031059
2 rowMins(X, cols, rows) 0.010078 0.0104890 0.0110174 0.0106715 0.0108695 0.041625
3 rowMins(X[cols, rows]) 0.016061 0.0163785 0.0174024 0.0166045 0.0169595 0.062957
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins(X, cols, rows) 1.235049 1.204801 1.202192 1.193613 1.197477 1.340191
3 rowMins(X[cols, rows]) 1.968260 1.881289 1.898901 1.857223 1.868404 2.027013

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

Table: Benchmarking of colMins_X_S() and rowMins_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
1 colMins_X_S 8.103 8.438 8.78207 8.5820 8.701 25.702
2 rowMins_X_S 8.160 8.706 9.16447 8.9405 9.077 31.059
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins_X_S 1.007034 1.031761 1.043543 1.041773 1.043213 1.208427

Figure: Benchmarking of colMins_X_S() and rowMins_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 3150238 168.3    5709258 305.0  5709258 305.0
Vcells 5781526  44.2   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3150229 168.3    5709258 305.0  5709258 305.0
Vcells 5786604  44.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.006183 0.0062850 0.0063967 0.0063365 0.0064430 0.009371
2 colMins(X, rows, cols) 0.007228 0.0073395 0.0078165 0.0074145 0.0075665 0.039725
3 colMins(X[rows, cols]) 0.013627 0.0138270 0.0143065 0.0139280 0.0141070 0.024549
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.00000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.169012 1.16778 1.221955 1.170125 1.174375 4.239142
3 colMins(X[rows, cols]) 2.203946 2.20000 2.236542 2.198059 2.189508 2.619678

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.007216 0.0073390 0.0078905 0.0074255 0.0075010 0.033257
2 rowMins(X, cols, rows) 0.009155 0.0093505 0.0096633 0.0094850 0.0096695 0.024208
3 rowMins(X[cols, rows]) 0.015824 0.0160805 0.0164912 0.0162175 0.0164025 0.027026
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowMins(X, cols, rows) 1.268708 1.274084 1.224670 1.277355 1.289095 0.7279069
3 rowMins(X[cols, rows]) 2.192905 2.191102 2.090008 2.184028 2.186708 0.8126409

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 6.183 6.285 6.39670 6.3365 6.443 9.371
2 rowMins_X_S 7.216 7.339 7.89051 7.4255 7.501 33.257
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins_X_S 1.167071 1.167701 1.233528 1.171861 1.164209 3.548928

Figure: Benchmarking of colMins_X_S() and rowMins_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 3150444 168.3    5709258 305.0  5709258 305.0
Vcells 5782340  44.2   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3150435 168.3    5709258 305.0  5709258 305.0
Vcells 5787418  44.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.015440 0.0160410 0.0173119 0.0164150 0.0169860 0.046489
2 colMins(X, rows, cols) 0.019607 0.0201470 0.0209749 0.0203700 0.0207395 0.056250
3 colMins(X[rows, cols]) 0.023891 0.0244125 0.0251839 0.0247105 0.0252860 0.036094
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 colMins(X, rows, cols) 1.269883 1.255969 1.211591 1.240938 1.220976 1.2099636
3 colMins(X[rows, cols]) 1.547345 1.521881 1.454717 1.505361 1.488638 0.7763987

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.014456 0.0153825 0.0161360 0.0157805 0.0162820 0.043553
2 rowMins(X, cols, rows) 0.016715 0.0180190 0.0184808 0.0184615 0.0189255 0.020548
3 rowMins(X[cols, rows]) 0.022135 0.0229640 0.0235515 0.0232960 0.0236960 0.041412
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowMins(X, cols, rows) 1.156267 1.171396 1.145312 1.169893 1.162357 0.4717930
3 rowMins(X[cols, rows]) 1.531198 1.492865 1.459560 1.476252 1.455350 0.9508415

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

Table: Benchmarking of colMins_X_S() and rowMins_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 rowMins_X_S 14.456 15.3825 16.13600 15.7805 16.282 43.553
1 colMins_X_S 15.440 16.0410 17.31188 16.4150 16.986 46.489
expr min lq mean median uq max
2 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colMins_X_S 1.068069 1.042808 1.072873 1.040208 1.043238 1.067412

Figure: Benchmarking of colMins_X_S() and rowMins_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 3150643 168.3    5709258 305.0  5709258 305.0
Vcells 5804991  44.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3150634 168.3    5709258 305.0  5709258 305.0
Vcells 5855069  44.7   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.074529 0.075641 0.0762584 0.0761645 0.0765605 0.081771
2 colMins(X, rows, cols) 0.090758 0.091161 0.0927088 0.0914220 0.0918360 0.182648
3 colMins(X[rows, cols]) 0.146650 0.147896 0.1490799 0.1486230 0.1489930 0.170045
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.217754 1.205180 1.215719 1.200323 1.199522 2.233652
3 colMins(X[rows, cols]) 1.967690 1.955236 1.954930 1.951342 1.946082 2.079527

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.078440 0.079221 0.0801926 0.079727 0.0801350 0.109325
2 rowMins(X, cols, rows) 0.091313 0.092270 0.0928305 0.092656 0.0930450 0.108169
3 rowMins(X[cols, rows]) 0.141716 0.142915 0.1445402 0.143378 0.1440585 0.202843
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins(X, cols, rows) 1.164113 1.164716 1.157594 1.162166 1.161103 0.989426
3 rowMins(X[cols, rows]) 1.806680 1.804004 1.802413 1.798362 1.797698 1.855413

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

Table: Benchmarking of colMins_X_S() and rowMins_X_S() on integer+100x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colMins_X_S 74.529 75.641 76.25841 76.1645 76.5605 81.771
2 rowMins_X_S 78.440 79.221 80.19262 79.7270 80.1350 109.325
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins_X_S 1.052476 1.047329 1.051591 1.046774 1.046689 1.336965

Figure: Benchmarking of colMins_X_S() and rowMins_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 3150859 168.3    5709258 305.0  5709258 305.0
Vcells 5805766  44.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3150850 168.3    5709258 305.0  5709258 305.0
Vcells 5855844  44.7   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.053750 0.0541305 0.0544439 0.0542410 0.0544095 0.058897
2 colMins(X, rows, cols) 0.059726 0.0601185 0.0605694 0.0604960 0.0607005 0.065516
3 colMins(X[rows, cols]) 0.116867 0.1175115 0.1202412 0.1177975 0.1182370 0.194267
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.111181 1.110622 1.112509 1.115319 1.115623 1.112383
3 colMins(X[rows, cols]) 2.174270 2.170893 2.208533 2.171743 2.173095 3.298419

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.059707 0.0601660 0.0630346 0.0604115 0.0608925 0.169952
2 rowMins(X, cols, rows) 0.078534 0.0792310 0.0818430 0.0795230 0.0803055 0.128880
3 rowMins(X[cols, rows]) 0.131064 0.1316015 0.1393021 0.1321350 0.1370090 0.269135
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowMins(X, cols, rows) 1.315323 1.316873 1.298382 1.316355 1.318808 0.7583318
3 rowMins(X[cols, rows]) 2.195120 2.187307 2.209931 2.187249 2.250014 1.5835942

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 53.750 54.1305 54.44393 54.2410 54.4095 58.897
2 rowMins_X_S 59.707 60.1660 63.03461 60.4115 60.8925 169.952
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.00000 1.000000 1.000000 1.00000
2 rowMins_X_S 1.110828 1.111499 1.15779 1.113761 1.119152 2.88558

Figure: Benchmarking of colMins_X_S() and rowMins_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 3151077 168.3    5709258 305.0  5709258 305.0
Vcells 5896853  45.0   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3151059 168.3    5709258 305.0  5709258 305.0
Vcells 5897016  45.0   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.000987 0.0010260 0.0013949 0.0010465 0.0011270 0.031114
2 colMins(X, rows, cols) 0.001153 0.0011995 0.0013034 0.0012150 0.0013055 0.004890
3 colMins(X[rows, cols]) 0.001630 0.0018660 0.0020711 0.0019350 0.0020550 0.010724
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.168186 1.169103 0.9344044 1.161013 1.158385 0.157164
3 colMins(X[rows, cols]) 1.651469 1.818714 1.4847266 1.849020 1.823425 0.344668

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.001023 0.0010795 0.0016327 0.0012580 0.0017550 0.018654
2 rowMins(X, cols, rows) 0.001190 0.0012325 0.0023524 0.0013935 0.0020980 0.033573
3 rowMins(X[cols, rows]) 0.001533 0.0018575 0.0034298 0.0021180 0.0031335 0.039438
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins(X, cols, rows) 1.163245 1.141732 1.440798 1.107711 1.195442 1.799775
3 rowMins(X[cols, rows]) 1.498534 1.720704 2.100666 1.683625 1.785470 2.114185

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 987 1026.0 1394.91 1046.5 1127 31114
2 rowMins_X_S 1023 1079.5 1632.72 1258.0 1755 18654
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowMins_X_S 1.036474 1.052144 1.170484 1.202102 1.557232 0.5995372

Figure: Benchmarking of colMins_X_S() and rowMins_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 3151276 168.3    5709258 305.0  5709258 305.0
Vcells 5902789  45.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3151270 168.3    5709258 305.0  5709258 305.0
Vcells 5912872  45.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.006184 0.0064265 0.0067068 0.0066085 0.0068255 0.013146
2 colMins(X, rows, cols) 0.009099 0.0097140 0.0101481 0.0099605 0.0101975 0.022566
3 colMins(X[rows, cols]) 0.021748 0.0222880 0.0230036 0.0224405 0.0226300 0.067610
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.471378 1.511554 1.513098 1.507226 1.494030 1.716568
3 colMins(X[rows, cols]) 3.516818 3.468140 3.429868 3.395703 3.315508 5.143009

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.008624 0.0089525 0.0116481 0.0092120 0.0150970 0.021944
2 rowMins(X, cols, rows) 0.009992 0.0103655 0.0135867 0.0106055 0.0178595 0.048137
3 rowMins(X[cols, rows]) 0.016129 0.0165445 0.0220870 0.0168990 0.0287240 0.093011
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins(X, cols, rows) 1.158627 1.157833 1.166431 1.151270 1.182983 2.193629
3 rowMins(X[cols, rows]) 1.870246 1.848031 1.896180 1.834455 1.902630 4.238562

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 6.184 6.4265 6.70685 6.6085 6.8255 13.146
2 rowMins_X_S 8.624 8.9525 11.64813 9.2120 15.0970 21.944
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.00000 1.000000 1.000000 1.000000 1.000000
2 rowMins_X_S 1.394567 1.39306 1.736751 1.393962 2.211853 1.669253

Figure: Benchmarking of colMins_X_S() and rowMins_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 3151488 168.4    5709258 305.0  5709258 305.0
Vcells 5904199  45.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3151479 168.4    5709258 305.0  5709258 305.0
Vcells 5914277  45.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.005218 0.0053155 0.0054704 0.0054300 0.0054990 0.009860
2 colMins(X, rows, cols) 0.008154 0.0083750 0.0090457 0.0084985 0.0085800 0.048029
3 colMins(X[rows, cols]) 0.021047 0.0211990 0.0214584 0.0212870 0.0214135 0.032305
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.562668 1.575581 1.653576 1.565101 1.560284 4.871095
3 colMins(X[rows, cols]) 4.033538 3.988148 3.922643 3.920258 3.894072 3.276369

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.007458 0.0076075 0.0081891 0.007714 0.0077895 0.034722
2 rowMins(X, cols, rows) 0.009870 0.0101720 0.0111585 0.010446 0.0106920 0.035507
3 rowMins(X[cols, rows]) 0.016553 0.0169660 0.0180078 0.017176 0.0173380 0.030484
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowMins(X, cols, rows) 1.323411 1.337101 1.362612 1.354161 1.372617 1.0226081
3 rowMins(X[cols, rows]) 2.219496 2.230168 2.198998 2.226601 2.225817 0.8779448

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 5.218 5.3155 5.47038 5.430 5.4990 9.860
2 rowMins_X_S 7.458 7.6075 8.18908 7.714 7.7895 34.722
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.00000 1.000000
2 rowMins_X_S 1.429283 1.431192 1.496986 1.420626 1.41653 3.521501

Figure: Benchmarking of colMins_X_S() and rowMins_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 3151694 168.4    5709258 305.0  5709258 305.0
Vcells 5904336  45.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3151685 168.4    5709258 305.0  5709258 305.0
Vcells 5914414  45.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.010482 0.0134415 0.0162633 0.014586 0.0162500 0.052851
2 colMins(X, rows, cols) 0.017086 0.0192615 0.0232485 0.020947 0.0248950 0.067751
3 colMins(X[rows, cols]) 0.020228 0.0232960 0.0318441 0.025182 0.0312335 0.115575
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.630032 1.432987 1.429507 1.436103 1.532000 1.281925
3 colMins(X[rows, cols]) 1.929784 1.733140 1.958032 1.726450 1.922062 2.186808

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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
2 rowMins(X, cols, rows) 0.014360 0.0156900 0.0165315 0.0161350 0.0167755 0.029744
1 rowMins_X_S 0.015690 0.0163115 0.0172034 0.0165235 0.0168680 0.047459
3 rowMins(X[cols, rows]) 0.023952 0.0245235 0.0256346 0.0247830 0.0252800 0.047143
expr min lq mean median uq max
2 rowMins(X, cols, rows) 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 rowMins_X_S 1.092618 1.039611 1.040648 1.024078 1.005514 1.595582
3 rowMins(X[cols, rows]) 1.667967 1.563002 1.550659 1.535978 1.506960 1.584958

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 10.482 13.4415 16.26332 14.5860 16.250 52.851
2 rowMins_X_S 15.690 16.3115 17.20343 16.5235 16.868 47.459
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowMins_X_S 1.496852 1.213518 1.057805 1.132833 1.038031 0.8979773

Figure: Benchmarking of colMins_X_S() and rowMins_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 3151893 168.4    5709258 305.0  5709258 305.0
Vcells 5949763  45.4   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3151884 168.4    5709258 305.0  5709258 305.0
Vcells 6049841  46.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.070654 0.0712260 0.0746335 0.0716570 0.0723480 0.179717
2 colMins(X, rows, cols) 0.101337 0.1029475 0.1096729 0.1034985 0.1051480 0.220491
3 colMins(X[rows, cols]) 0.217890 0.2197500 0.2396077 0.2211550 0.2343535 0.519751
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.00000 1.000000 1.000000
2 colMins(X, rows, cols) 1.434271 1.445364 1.469487 1.44436 1.453364 1.226879
3 colMins(X[rows, cols]) 3.083902 3.085250 3.210460 3.08630 3.239253 2.892053

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.080057 0.080788 0.0817613 0.0810945 0.0815165 0.113188
2 rowMins(X, cols, rows) 0.104103 0.104787 0.1060515 0.1050740 0.1055220 0.159154
3 rowMins(X[cols, rows]) 0.149685 0.151002 0.1542423 0.1516635 0.1533200 0.264747
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins(X, cols, rows) 1.300361 1.297061 1.297087 1.295698 1.294486 1.406103
3 rowMins(X[cols, rows]) 1.869730 1.869114 1.886495 1.870207 1.880846 2.339002

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 70.654 71.226 74.63346 71.6570 72.3480 179.717
2 rowMins_X_S 80.057 80.788 81.76130 81.0945 81.5165 113.188
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowMins_X_S 1.133085 1.134249 1.095505 1.131704 1.126728 0.6298124

Figure: Benchmarking of colMins_X_S() and rowMins_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 3152109 168.4    5709258 305.0  5709258 305.0
Vcells 5949910  45.4   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMins_X_S = colMins(X_S, na.rm = FALSE), `colMins(X, rows, cols)` = colMins(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colMins(X[rows, cols])` = colMins(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 3152100 168.4    5709258 305.0  5709258 305.0
Vcells 6049988  46.2   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMins_X_S = rowMins(X_S, na.rm = FALSE), `rowMins(X, cols, rows)` = rowMins(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowMins(X[cols, rows])` = rowMins(X[cols, rows], na.rm = FALSE), 
+     unit = "ms")

Table: Benchmarking of colMins_X_S(), colMins(X, rows, cols)() and colMins(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 colMins_X_S 0.044510 0.0449825 0.0457728 0.0451525 0.045462 0.057656
2 colMins(X, rows, cols) 0.070959 0.0713125 0.0720262 0.0715020 0.071623 0.103060
3 colMins(X[rows, cols]) 0.112394 0.1137555 0.1185828 0.1155100 0.117261 0.259433
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colMins(X, rows, cols) 1.594226 1.585339 1.573556 1.583567 1.575448 1.787498
3 colMins(X[rows, cols]) 2.525140 2.528884 2.590681 2.558219 2.579319 4.499670

Table: Benchmarking of rowMins_X_S(), rowMins(X, cols, rows)() and rowMins(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 rowMins_X_S 0.062235 0.0626185 0.0632144 0.0628505 0.0632145 0.072205
2 rowMins(X, cols, rows) 0.087341 0.0878650 0.0885488 0.0881050 0.0883595 0.097590
3 rowMins(X[cols, rows]) 0.136805 0.1380775 0.1413012 0.1389720 0.1399780 0.273315
expr min lq mean median uq max
1 rowMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins(X, cols, rows) 1.403406 1.403180 1.400771 1.401819 1.397773 1.351568
3 rowMins(X[cols, rows]) 2.198200 2.205059 2.235271 2.211152 2.214334 3.785264

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

Table: Benchmarking of colMins_X_S() and rowMins_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 colMins_X_S 44.510 44.9825 45.77285 45.1525 45.4620 57.656
2 rowMins_X_S 62.235 62.6185 63.21435 62.8505 63.2145 72.205
expr min lq mean median uq max
1 colMins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowMins_X_S 1.398225 1.392064 1.381045 1.391961 1.390491 1.252341

Figure: Benchmarking of colMins_X_S() and rowMins_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.58 secs.

Reproducibility

To reproduce this report, do:

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

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