colRowAnys_subset - HenrikBengtsson/matrixStats GitHub Wiki

matrixStats: Benchmark report


colAnys() and rowAnys() benchmarks on subsetted computation

This report benchmark the performance of colAnys() and rowAnys() on subsetted computation.

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 = "logical")

Results

10x10 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 3074487 164.2    5709258 305.0  5709258 305.0
Vcells 5562356  42.5   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3073415 164.2    5709258 305.0  5709258 305.0
Vcells 5559586  42.5   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colAnys_X_S 0.001356 0.0013930 0.0017866 0.0014200 0.0015050 0.032118
2 colAnys(X, rows, cols) 0.001524 0.0015715 0.0016938 0.0016095 0.0017605 0.004875
3 colAnys(X[rows, cols]) 0.002085 0.0022755 0.0025050 0.0023670 0.0024930 0.010202
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colAnys(X, rows, cols) 1.123894 1.128141 0.9480516 1.133451 1.169767 0.1517840
3 colAnys(X[rows, cols]) 1.537611 1.633525 1.4021035 1.666901 1.656478 0.3176412

Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on 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 rowAnys_X_S 0.001364 0.0014030 0.0015140 0.001437 0.0015250 0.003704
2 rowAnys(X, cols, rows) 0.001585 0.0016445 0.0021096 0.001670 0.0018735 0.036419
3 rowAnys(X[cols, rows]) 0.001948 0.0021695 0.0025403 0.002287 0.0024125 0.015965
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys(X, cols, rows) 1.162024 1.172131 1.393456 1.162143 1.228525 9.832343
3 rowAnys(X[cols, rows]) 1.428152 1.546329 1.677913 1.591510 1.581967 4.310205

Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 10x10 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 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 colAnys_X_S 1.356 1.393 1.78658 1.420 1.505 32.118
2 rowAnys_X_S 1.364 1.403 1.51397 1.437 1.525 3.704
expr min lq mean median uq max
1 colAnys_X_S 1.0000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 rowAnys_X_S 1.0059 1.007179 0.8474124 1.011972 1.013289 0.1153247

Figure: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 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 3071909 164.1    5709258 305.0  5709258 305.0
Vcells 5227681  39.9   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3071903 164.1    5709258 305.0  5709258 305.0
Vcells 5232764  40.0   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colAnys_X_S 0.001899 0.0021305 0.0022950 0.0022515 0.0023810 0.005052
2 colAnys(X, rows, cols) 0.002252 0.0025330 0.0028043 0.0026585 0.0028205 0.010225
3 colAnys(X[rows, cols]) 0.017541 0.0177730 0.0184920 0.0179225 0.0181725 0.057294
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colAnys(X, rows, cols) 1.185887 1.188923 1.221883 1.180768 1.184586 2.023951
3 colAnys(X[rows, cols]) 9.236967 8.342173 8.057389 7.960249 7.632297 11.340855

Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on 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 rowAnys_X_S 0.004288 0.0045325 0.0046608 0.004629 0.0047535 0.006961
2 rowAnys(X, cols, rows) 0.004684 0.0048875 0.0050583 0.005001 0.0051535 0.007404
3 rowAnys(X[cols, rows]) 0.011358 0.0116880 0.0124336 0.011819 0.0120495 0.049704
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys(X, cols, rows) 1.092351 1.078323 1.085297 1.080363 1.084148 1.063640
3 rowAnys(X[cols, rows]) 2.648787 2.578709 2.667732 2.553251 2.534869 7.140353

Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 100x100 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 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 colAnys_X_S 1.899 2.1305 2.29504 2.2515 2.3810 5.052
2 rowAnys_X_S 4.288 4.5325 4.66075 4.6290 4.7535 6.961
expr min lq mean median uq max
1 colAnys_X_S 1.00000 1.000000 1.000000 1.000000 1.00000 1.00000
2 rowAnys_X_S 2.25803 2.127435 2.030793 2.055963 1.99643 1.37787

Figure: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 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 3072663 164.1    5709258 305.0  5709258 305.0
Vcells 5231753  40.0   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3072654 164.1    5709258 305.0  5709258 305.0
Vcells 5236831  40.0   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colAnys_X_S 0.001355 0.0014415 0.0015528 0.001504 0.0016045 0.004313
2 colAnys(X, rows, cols) 0.002147 0.0022315 0.0025625 0.002302 0.0023915 0.025150
3 colAnys(X[rows, cols]) 0.016088 0.0166010 0.0170227 0.016715 0.0168990 0.032261
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.00000 1.000000 1.000000 1.000000 1.000000
2 colAnys(X, rows, cols) 1.584502 1.54804 1.650239 1.530585 1.490495 5.831208
3 colAnys(X[rows, cols]) 11.873063 11.51648 10.962353 11.113697 10.532253 7.479944

Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on 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 rowAnys_X_S 0.004583 0.005022 0.0053577 0.0050665 0.0052030 0.033800
2 rowAnys(X, cols, rows) 0.005105 0.005268 0.0054948 0.0053960 0.0055455 0.010779
3 rowAnys(X[cols, rows]) 0.013506 0.013847 0.0145027 0.0140710 0.0142960 0.033346
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.113899 1.048984 1.025595 1.065035 1.065827 0.3189053
3 rowAnys(X[cols, rows]) 2.946978 2.757268 2.706917 2.777262 2.747646 0.9865680

Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 1000x10 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 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 colAnys_X_S 1.355 1.4415 1.55283 1.5040 1.6045 4.313
2 rowAnys_X_S 4.583 5.0220 5.35766 5.0665 5.2030 33.800
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys_X_S 3.382288 3.483871 3.450255 3.368683 3.242755 7.836773

Figure: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 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 3072866 164.2    5709258 305.0  5709258 305.0
Vcells 5232551  40.0   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3072860 164.2    5709258 305.0  5709258 305.0
Vcells 5237634  40.0   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colAnys_X_S 0.004855 0.0051615 0.0056257 0.005482 0.0058970 0.011418
2 colAnys(X, rows, cols) 0.008077 0.0094130 0.0100815 0.009698 0.0100265 0.043876
3 colAnys(X[rows, cols]) 0.013571 0.0140430 0.0146889 0.014408 0.0148745 0.023496
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colAnys(X, rows, cols) 1.663646 1.823695 1.792040 1.769062 1.700271 3.842704
3 colAnys(X[rows, cols]) 2.795263 2.720721 2.611033 2.628238 2.522384 2.057803

Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on 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 rowAnys_X_S 0.009044 0.0098765 0.0149362 0.0102615 0.0108710 0.200069
2 rowAnys(X, cols, rows) 0.009850 0.0114350 0.0141290 0.0120690 0.0128595 0.041426
3 rowAnys(X[cols, rows]) 0.016586 0.0173130 0.0233150 0.0178590 0.0183900 0.164487
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.089120 1.157799 0.945956 1.176144 1.182918 0.2070586
3 rowAnys(X[cols, rows]) 1.833923 1.752949 1.560976 1.740389 1.691657 0.8221514

Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 10x1000 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 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 colAnys_X_S 4.855 5.1615 5.62569 5.4820 5.897 11.418
2 rowAnys_X_S 9.044 9.8765 14.93616 10.2615 10.871 200.069
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.00000 1.00000
2 rowAnys_X_S 1.862822 1.913494 2.654992 1.871853 1.84348 17.52225

Figure: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 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 3073065 164.2    5709258 305.0  5709258 305.0
Vcells 5255196  40.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3073059 164.2    5709258 305.0  5709258 305.0
Vcells 5305279  40.5   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colAnys_X_S 0.005351 0.0061920 0.0077397 0.0068515 0.007864 0.025802
2 colAnys(X, rows, cols) 0.009326 0.0120895 0.0143827 0.0131150 0.013843 0.068032
3 colAnys(X[rows, cols]) 0.152655 0.1552720 0.1678322 0.1606905 0.166528 0.354265
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.00000 1.000000
2 colAnys(X, rows, cols) 1.742852 1.952439 1.858294 1.914179 1.76030 2.636695
3 colAnys(X[rows, cols]) 28.528312 25.076227 21.684563 23.453331 21.17599 13.730137

Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on 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 rowAnys_X_S 0.042043 0.0438890 0.0454123 0.0446005 0.045449 0.084432
2 rowAnys(X, cols, rows) 0.042650 0.0442855 0.0455195 0.0453670 0.046423 0.056537
3 rowAnys(X[cols, rows]) 0.123326 0.1266025 0.1302286 0.1282850 0.129231 0.195170
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.014438 1.009034 1.002360 1.017186 1.021431 0.6696158
3 rowAnys(X[cols, rows]) 2.933330 2.884607 2.867693 2.876313 2.843429 2.3115643

Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 100x1000 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 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 colAnys_X_S 5.351 6.192 7.73971 6.8515 7.864 25.802
2 rowAnys_X_S 42.043 43.889 45.41231 44.6005 45.449 84.432
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys_X_S 7.857036 7.088017 5.867443 6.509596 5.779374 3.272305

Figure: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 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 3073281 164.2    5709258 305.0  5709258 305.0
Vcells 5255863  40.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3073275 164.2    5709258 305.0  5709258 305.0
Vcells 5305946  40.5   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colAnys_X_S 0.002617 0.0028565 0.0031919 0.0030350 0.0032470 0.010359
2 colAnys(X, rows, cols) 0.003639 0.0039855 0.0044078 0.0042635 0.0044615 0.011315
3 colAnys(X[rows, cols]) 0.081950 0.0824815 0.0853578 0.0828950 0.0845325 0.184085
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.00000 1.000000 1.000000 1.000000
2 colAnys(X, rows, cols) 1.390524 1.395239 1.38093 1.404778 1.374038 1.092287
3 colAnys(X[rows, cols]) 31.314482 28.875022 26.74199 27.313015 26.034031 17.770538

Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on 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 rowAnys_X_S 0.028460 0.0287755 0.0294075 0.0289865 0.0293925 0.043539
2 rowAnys(X, cols, rows) 0.028699 0.0290525 0.0294747 0.0293630 0.0297725 0.031693
3 rowAnys(X[cols, rows]) 0.093992 0.0946480 0.0976003 0.0953205 0.0974690 0.195697
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.008398 1.009626 1.002285 1.012989 1.012928 0.7279221
3 rowAnys(X[cols, rows]) 3.302600 3.289187 3.318894 3.288445 3.316118 4.4947518

Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 1000x100 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 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 colAnys_X_S 2.617 2.8565 3.19190 3.0350 3.2470 10.359
2 rowAnys_X_S 28.460 28.7755 29.40748 28.9865 29.3925 43.539
expr min lq mean median uq max
1 colAnys_X_S 1.00000 1.00000 1.000000 1.000000 1.000000 1.000000
2 rowAnys_X_S 10.87505 10.07369 9.213158 9.550741 9.052202 4.203012

Figure: Benchmarking of colAnys_X_S() and rowAnys_X_S() on 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 11.83 secs.

Reproducibility

To reproduce this report, do:

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

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