colRowAlls - HenrikBengtsson/matrixStats GitHub Wiki
matrixStats: Benchmark report
This report benchmark the performance of colAlls() and rowAlls() against alternative methods.
- apply() + all()
- colSums() == n or rowSums() == n
> 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")> X <- data[["10x10"]]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3062839 163.6    5709258 305.0  5709258 305.0
Vcells 5337890  40.8   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAlls = colAlls(X), `apply+all` = apply(X, MARGIN = 2L, FUN = all), 
+     `colSums==n` = (colSums(X) == nrow(X)), unit = "ms")
> X <- t(X)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061972 163.6    5709258 305.0  5709258 305.0
Vcells 5335730  40.8   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAlls = rowAlls(X), `apply+all` = apply(X, MARGIN = 1L, FUN = all), 
+     `rowSums==n` = (rowSums(X) == ncol(X)), unit = "ms")Table: Benchmarking of colAlls(), apply+all() and colSums==n() 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 | colAlls | 0.001456 | 0.0016925 | 0.0021430 | 0.0020870 | 0.0022825 | 0.014512 | 
| 3 | colSums==n | 0.003712 | 0.0040890 | 0.0052483 | 0.0046245 | 0.0052255 | 0.058173 | 
| 2 | apply+all | 0.019053 | 0.0197280 | 0.0207568 | 0.0200725 | 0.0204470 | 0.064866 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | colSums==n | 2.54945 | 2.415953 | 2.449002 | 2.215860 | 2.289376 | 4.008614 | 
| 2 | apply+all | 13.08585 | 11.656130 | 9.685704 | 9.617873 | 8.958160 | 4.469818 | 
Table: Benchmarking of rowAlls(), apply+all() and rowSums==n() 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 | rowAlls | 0.001317 | 0.0015415 | 0.0020103 | 0.0019760 | 0.0021695 | 0.014576 | 
| 3 | rowSums==n | 0.003993 | 0.0044455 | 0.0053485 | 0.0048405 | 0.0053980 | 0.047883 | 
| 2 | apply+all | 0.018248 | 0.0190860 | 0.0201142 | 0.0194350 | 0.0198600 | 0.067070 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | rowSums==n | 3.031891 | 2.883879 | 2.660601 | 2.449646 | 2.488131 | 3.285058 | 
| 2 | apply+all | 13.855733 | 12.381447 | 10.005750 | 9.835526 | 9.154183 | 4.601400 | 
Figure: Benchmarking of colAlls(), apply+all() and colSums==n() on 10x10 data as well as rowAlls(), apply+all() and rowSums==n() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

 Table: Benchmarking of colAlls() and rowAlls() on 10x10 data (original and transposed).  The top panel shows times in milliseconds and the bottom panel shows relative times.
Table: Benchmarking of colAlls() and rowAlls() 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 | |
|---|---|---|---|---|---|---|---|
| 2 | rowAlls | 1.317 | 1.5415 | 2.01026 | 1.976 | 2.1695 | 14.576 | 
| 1 | colAlls | 1.456 | 1.6925 | 2.14304 | 2.087 | 2.2825 | 14.512 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 
| 1 | colAlls | 1.105543 | 1.097957 | 1.066051 | 1.056174 | 1.052086 | 0.9956092 | 
Figure: Benchmarking of colAlls() and rowAlls() on 10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x100"]]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3060526 163.5    5709258 305.0  5709258 305.0
Vcells 5141926  39.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAlls = colAlls(X), `apply+all` = apply(X, MARGIN = 2L, FUN = all), 
+     `colSums==n` = (colSums(X) == nrow(X)), unit = "ms")
> X <- t(X)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3060520 163.5    5709258 305.0  5709258 305.0
Vcells 5146969  39.3   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAlls = rowAlls(X), `apply+all` = apply(X, MARGIN = 1L, FUN = all), 
+     `rowSums==n` = (rowSums(X) == ncol(X)), unit = "ms")Table: Benchmarking of colAlls(), apply+all() and colSums==n() 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 | colAlls | 0.001991 | 0.0024595 | 0.0030387 | 0.0030415 | 0.0033560 | 0.013028 | 
| 3 | colSums==n | 0.011997 | 0.0128015 | 0.0138879 | 0.0137880 | 0.0142750 | 0.028365 | 
| 2 | apply+all | 0.170807 | 0.1723080 | 0.1772172 | 0.1734345 | 0.1762225 | 0.284037 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.00000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 
| 3 | colSums==n | 6.025615 | 5.20492 | 4.570314 | 4.53329 | 4.253576 | 2.177234 | 
| 2 | apply+all | 85.789553 | 70.05814 | 58.319869 | 57.02269 | 52.509684 | 21.802042 | 
Table: Benchmarking of rowAlls(), apply+all() and rowSums==n() 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 | rowAlls | 0.005430 | 0.005711 | 0.0063150 | 0.0061340 | 0.0064950 | 0.018429 | 
| 3 | rowSums==n | 0.035304 | 0.035952 | 0.0366582 | 0.0365790 | 0.0370105 | 0.048019 | 
| 2 | apply+all | 0.128607 | 0.130724 | 0.1357184 | 0.1313515 | 0.1341430 | 0.266220 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowAlls | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | rowSums==n | 6.501658 | 6.29522 | 5.804955 | 5.963319 | 5.698306 | 2.605622 | 
| 2 | apply+all | 23.684530 | 22.88986 | 21.491475 | 21.413678 | 20.653272 | 14.445711 | 
Figure: Benchmarking of colAlls(), apply+all() and colSums==n() on 100x100 data as well as rowAlls(), apply+all() and rowSums==n() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

 Table: Benchmarking of colAlls() and rowAlls() on 100x100 data (original and transposed).  The top panel shows times in milliseconds and the bottom panel shows relative times.
Table: Benchmarking of colAlls() and rowAlls() 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 | colAlls | 1.991 | 2.4595 | 3.03871 | 3.0415 | 3.356 | 13.028 | 
| 2 | rowAlls | 5.430 | 5.7110 | 6.31499 | 6.1340 | 6.495 | 18.429 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 
| 2 | rowAlls | 2.727273 | 2.322017 | 2.078181 | 2.016768 | 1.93534 | 1.414569 | 
Figure: Benchmarking of colAlls() and rowAlls() on 100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x10"]]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061281 163.5    5709258 305.0  5709258 305.0
Vcells 5145460  39.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAlls = colAlls(X), `apply+all` = apply(X, MARGIN = 2L, FUN = all), 
+     `colSums==n` = (colSums(X) == nrow(X)), unit = "ms")
> X <- t(X)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061272 163.5    5709258 305.0  5709258 305.0
Vcells 5150498  39.3   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAlls = rowAlls(X), `apply+all` = apply(X, MARGIN = 1L, FUN = all), 
+     `rowSums==n` = (rowSums(X) == ncol(X)), unit = "ms")Table: Benchmarking of colAlls(), apply+all() and colSums==n() 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 | colAlls | 0.001435 | 0.0017835 | 0.0022827 | 0.0022645 | 0.0025915 | 0.011481 | 
| 3 | colSums==n | 0.011634 | 0.0121230 | 0.0130242 | 0.0128585 | 0.0135305 | 0.026541 | 
| 2 | apply+all | 0.104368 | 0.1063765 | 0.1080376 | 0.1072015 | 0.1078570 | 0.163115 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | colSums==n | 8.107317 | 6.797309 | 5.705521 | 5.678295 | 5.221107 | 2.311732 | 
| 2 | apply+all | 72.730314 | 59.644800 | 47.328023 | 47.340031 | 41.619525 | 14.207386 | 
Table: Benchmarking of rowAlls(), apply+all() and rowSums==n() 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 | rowAlls | 0.005958 | 0.006369 | 0.0072919 | 0.006920 | 0.0076210 | 0.035577 | 
| 2 | apply+all | 0.062092 | 0.064786 | 0.0664165 | 0.065730 | 0.0665915 | 0.119653 | 
| 3 | rowSums==n | 0.133095 | 0.133928 | 0.1350352 | 0.134499 | 0.1349295 | 0.159741 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowAlls | 1.00000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 2 | apply+all | 10.42162 | 10.17208 | 9.108271 | 9.498555 | 8.737895 | 3.363212 | 
| 3 | rowSums==n | 22.33887 | 21.02810 | 18.518541 | 19.436272 | 17.704960 | 4.490008 | 
Figure: Benchmarking of colAlls(), apply+all() and colSums==n() on 1000x10 data as well as rowAlls(), apply+all() and rowSums==n() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

 Table: Benchmarking of colAlls() and rowAlls() on 1000x10 data (original and transposed).  The top panel shows times in milliseconds and the bottom panel shows relative times.
Table: Benchmarking of colAlls() and rowAlls() 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 | colAlls | 1.435 | 1.7835 | 2.28274 | 2.2645 | 2.5915 | 11.481 | 
| 2 | rowAlls | 5.958 | 6.3690 | 7.29189 | 6.9200 | 7.6210 | 35.577 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 2 | rowAlls | 4.151916 | 3.571068 | 3.194358 | 3.055862 | 2.940768 | 3.098772 | 
Figure: Benchmarking of colAlls() and rowAlls() on 1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["10x1000"]]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061483 163.6    5709258 305.0  5709258 305.0
Vcells 5146180  39.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAlls = colAlls(X), `apply+all` = apply(X, MARGIN = 2L, FUN = all), 
+     `colSums==n` = (colSums(X) == nrow(X)), unit = "ms")
> X <- t(X)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061477 163.6    5709258 305.0  5709258 305.0
Vcells 5151223  39.4   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAlls = rowAlls(X), `apply+all` = apply(X, MARGIN = 1L, FUN = all), 
+     `rowSums==n` = (rowSums(X) == ncol(X)), unit = "ms")Table: Benchmarking of colAlls(), apply+all() and colSums==n() 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 | colAlls | 0.008884 | 0.010476 | 0.0122303 | 0.0118190 | 0.013187 | 0.025558 | 
| 3 | colSums==n | 0.013942 | 0.015299 | 0.0173466 | 0.0166725 | 0.018284 | 0.033008 | 
| 2 | apply+all | 0.749683 | 0.789936 | 0.8352648 | 0.8179545 | 0.861084 | 1.281145 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | colSums==n | 1.569338 | 1.460386 | 1.418328 | 1.410652 | 1.386517 | 1.291494 | 
| 2 | apply+all | 84.385750 | 75.404353 | 68.294713 | 69.206743 | 65.297945 | 50.126966 | 
Table: Benchmarking of rowAlls(), apply+all() and rowSums==n() 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 | rowAlls | 0.013450 | 0.0158825 | 0.0182027 | 0.0171120 | 0.0191295 | 0.040438 | 
| 3 | rowSums==n | 0.028157 | 0.0299995 | 0.0325026 | 0.0312035 | 0.0327855 | 0.081287 | 
| 2 | apply+all | 0.750827 | 0.7848980 | 0.8408515 | 0.8123460 | 0.8575355 | 1.320873 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowAlls | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | rowSums==n | 2.093457 | 1.88884 | 1.785592 | 1.823486 | 1.713871 | 2.010164 | 
| 2 | apply+all | 55.823569 | 49.41905 | 46.193802 | 47.472300 | 44.827910 | 32.664153 | 
Figure: Benchmarking of colAlls(), apply+all() and colSums==n() on 10x1000 data as well as rowAlls(), apply+all() and rowSums==n() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

 Table: Benchmarking of colAlls() and rowAlls() on 10x1000 data (original and transposed).  The top panel shows times in milliseconds and the bottom panel shows relative times.
Table: Benchmarking of colAlls() and rowAlls() 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 | colAlls | 8.884 | 10.4760 | 12.23030 | 11.819 | 13.1870 | 25.558 | 
| 2 | rowAlls | 13.450 | 15.8825 | 18.20269 | 17.112 | 19.1295 | 40.438 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 2 | rowAlls | 1.513958 | 1.516084 | 1.488327 | 1.447838 | 1.450633 | 1.582205 | 
Figure: Benchmarking of colAlls() and rowAlls() on 10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x1000"]]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061703 163.6    5709258 305.0  5709258 305.0
Vcells 5146710  39.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAlls = colAlls(X), `apply+all` = apply(X, MARGIN = 2L, FUN = all), 
+     `colSums==n` = (colSums(X) == nrow(X)), unit = "ms")
> X <- t(X)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061691 163.6    5709258 305.0  5709258 305.0
Vcells 5196743  39.7   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAlls = rowAlls(X), `apply+all` = apply(X, MARGIN = 1L, FUN = all), 
+     `rowSums==n` = (rowSums(X) == ncol(X)), unit = "ms")Table: Benchmarking of colAlls(), apply+all() and colSums==n() 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 | colAlls | 0.010682 | 0.0123640 | 0.0148551 | 0.0131580 | 0.0153845 | 0.064374 | 
| 3 | colSums==n | 0.083959 | 0.0886235 | 0.0931459 | 0.0914115 | 0.0942260 | 0.149290 | 
| 2 | apply+all | 1.574836 | 1.6613425 | 1.7092781 | 1.7042370 | 1.7260300 | 2.316910 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | colSums==n | 7.859858 | 7.167866 | 6.270311 | 6.947218 | 6.124736 | 2.319104 | 
| 2 | apply+all | 147.428946 | 134.369338 | 115.063617 | 129.520976 | 112.192791 | 35.991394 | 
Table: Benchmarking of rowAlls(), apply+all() and rowSums==n() 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 | rowAlls | 0.038797 | 0.0412470 | 0.0431752 | 0.042569 | 0.0446765 | 0.060725 | 
| 3 | rowSums==n | 0.224029 | 0.2295035 | 0.2348777 | 0.236617 | 0.2387210 | 0.265381 | 
| 2 | apply+all | 1.158340 | 1.2152695 | 1.2458592 | 1.234323 | 1.2673915 | 1.555215 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowAlls | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 
| 3 | rowSums==n | 5.77439 | 5.564126 | 5.440107 | 5.558434 | 5.343324 | 4.37021 | 
| 2 | apply+all | 29.85643 | 29.463222 | 28.855899 | 28.995819 | 28.368191 | 25.61079 | 
Figure: Benchmarking of colAlls(), apply+all() and colSums==n() on 100x1000 data as well as rowAlls(), apply+all() and rowSums==n() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

 Table: Benchmarking of colAlls() and rowAlls() on 100x1000 data (original and transposed).  The top panel shows times in milliseconds and the bottom panel shows relative times.
Table: Benchmarking of colAlls() and rowAlls() 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 | colAlls | 10.682 | 12.364 | 14.85507 | 13.158 | 15.3845 | 64.374 | 
| 2 | rowAlls | 38.797 | 41.247 | 43.17520 | 42.569 | 44.6765 | 60.725 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 
| 2 | rowAlls | 3.631998 | 3.336056 | 2.906429 | 3.235218 | 2.903994 | 0.9433156 | 
Figure: Benchmarking of colAlls() and rowAlls() on 100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x100"]]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061915 163.6    5709258 305.0  5709258 305.0
Vcells 5147379  39.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colAlls = colAlls(X), `apply+all` = apply(X, MARGIN = 2L, FUN = all), 
+     `colSums==n` = (colSums(X) == nrow(X)), unit = "ms")
> X <- t(X)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3061903 163.6    5709258 305.0  5709258 305.0
Vcells 5197412  39.7   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowAlls = rowAlls(X), `apply+all` = apply(X, MARGIN = 1L, FUN = all), 
+     `rowSums==n` = (rowSums(X) == ncol(X)), unit = "ms")Table: Benchmarking of colAlls(), apply+all() and colSums==n() 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 | colAlls | 0.002035 | 0.0028485 | 0.003774 | 0.0032960 | 0.0041875 | 0.013992 | 
| 3 | colSums==n | 0.082210 | 0.0830130 | 0.085607 | 0.0848105 | 0.0872915 | 0.101987 | 
| 2 | apply+all | 0.486788 | 0.4983560 | 0.510808 | 0.5038850 | 0.5200695 | 0.642772 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.00000 | 1.00000 | 1.0000 | 1.00000 | 1.00000 | 1.000000 | 
| 3 | colSums==n | 40.39803 | 29.14271 | 22.6833 | 25.73134 | 20.84573 | 7.288951 | 
| 2 | apply+all | 239.20786 | 174.95384 | 135.3489 | 152.87773 | 124.19570 | 45.938536 | 
Table: Benchmarking of rowAlls(), apply+all() and rowSums==n() 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 | rowAlls | 0.040659 | 0.0415455 | 0.0441671 | 0.0432225 | 0.0449320 | 0.067793 | 
| 3 | rowSums==n | 0.322712 | 0.3248410 | 0.3387711 | 0.3402920 | 0.3443395 | 0.410126 | 
| 2 | apply+all | 0.516653 | 0.5375725 | 0.5625644 | 0.5458500 | 0.5586570 | 1.268665 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowAlls | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 
| 3 | rowSums==n | 7.937037 | 7.818921 | 7.670212 | 7.873029 | 7.663569 | 6.049681 | 
| 2 | apply+all | 12.706978 | 12.939368 | 12.737180 | 12.628839 | 12.433388 | 18.713805 | 
Figure: Benchmarking of colAlls(), apply+all() and colSums==n() on 1000x100 data as well as rowAlls(), apply+all() and rowSums==n() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

 Table: Benchmarking of colAlls() and rowAlls() on 1000x100 data (original and transposed).  The top panel shows times in milliseconds and the bottom panel shows relative times.
Table: Benchmarking of colAlls() and rowAlls() 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 | colAlls | 2.035 | 2.8485 | 3.77401 | 3.2960 | 4.1875 | 13.992 | 
| 2 | rowAlls | 40.659 | 41.5455 | 44.16711 | 43.2225 | 44.9320 | 67.793 | 
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colAlls | 1.00000 | 1.00000 | 1.00000 | 1.00000 | 1.00000 | 1.000000 | 
| 2 | rowAlls | 19.97985 | 14.58504 | 11.70297 | 13.11362 | 10.73003 | 4.845126 | 
Figure: Benchmarking of colAlls() and rowAlls() on 1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

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