-
Notifications
You must be signed in to change notification settings - Fork 0
colRowMins
matrixStats: Benchmark report
This report benchmark the performance of colMins() and rowMins() against alternative methods.
- apply() + min()
- lapply() + pmin()
- lapply() + pmin.int()
See also StackOverflow:colMins?.
> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100,
+ +100), naProb = 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 (naProb > 0)
+ X[sample(n, size = naProb * 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)> X <- data[["10x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 657452 35.2 1168576 62.5 1168576 62.5
Vcells 12137829 92.7 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655366 35.1 1168576 62.5 1168576 62.5
Vcells 12131878 92.6 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0062 | 0.0096 | 0.0110 | 0.0102 | 0.0104 | 0.1263 |
| 4 | lapply+pmin.int | 0.0516 | 0.0562 | 0.0581 | 0.0570 | 0.0581 | 0.1301 |
| 3 | lapply+pmin | 0.0832 | 0.0874 | 0.0914 | 0.0885 | 0.0905 | 0.1967 |
| 2 | apply+min | 0.1043 | 0.1086 | 0.1114 | 0.1101 | 0.1122 | 0.1909 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 8.373 | 5.839 | 5.286 | 5.585 | 5.592 | 1.030 |
| 3 | lapply+pmin | 13.496 | 9.079 | 8.313 | 8.679 | 8.703 | 1.558 |
| 2 | apply+min | 16.933 | 11.279 | 10.135 | 10.792 | 10.795 | 1.512 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0027 | 0.0042 | 0.0082 | 0.0062 | 0.0071 | 0.1848 |
| 4 | lapply+pmin.int | 0.0231 | 0.0298 | 0.0391 | 0.0321 | 0.0556 | 0.0670 |
| 3 | lapply+pmin | 0.0431 | 0.0470 | 0.0615 | 0.0497 | 0.0866 | 0.0935 |
| 2 | apply+min | 0.0550 | 0.0602 | 0.0748 | 0.0631 | 0.1059 | 0.1332 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 | 1.0000 |
| 4 | lapply+pmin.int | 8.568 | 7.043 | 4.744 | 5.217 | 7.81 | 0.3625 |
| 3 | lapply+pmin | 15.993 | 11.087 | 7.460 | 8.060 | 12.16 | 0.5063 |
| 2 | apply+min | 20.419 | 14.222 | 9.079 | 10.247 | 14.86 | 0.7208 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on integer+10x10 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() on integer+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 2.696 | 4.236 | 8.239 | 6.161 | 7.122 | 184.8 |
| 1 | colMins | 6.161 | 9.625 | 10.995 | 10.202 | 10.395 | 126.3 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 | 1.0000 |
| 1 | colMins | 2.285 | 2.272 | 1.335 | 1.656 | 1.46 | 0.6833 |
| Figure: Benchmarking of colMins() and rowMins() on integer+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 655473 35.1 1168576 62.5 1168576 62.5
Vcells 12133218 92.6 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655467 35.1 1168576 62.5 1168576 62.5
Vcells 12138325 92.7 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0246 | 0.0383 | 0.0506 | 0.0487 | 0.0599 | 0.1132 |
| 4 | lapply+pmin.int | 0.3622 | 0.6028 | 0.6400 | 0.6444 | 0.6970 | 1.3504 |
| 2 | apply+min | 0.4161 | 0.7085 | 0.9151 | 0.7886 | 0.8635 | 11.9982 |
| 3 | lapply+pmin | 0.4696 | 0.6246 | 0.7723 | 0.8288 | 0.8802 | 1.1202 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.000 |
| 4 | lapply+pmin.int | 14.70 | 15.74 | 12.65 | 13.23 | 11.64 | 11.932 |
| 2 | apply+min | 16.89 | 18.50 | 18.09 | 16.19 | 14.42 | 106.013 |
| 3 | lapply+pmin | 19.06 | 16.31 | 15.26 | 17.02 | 14.70 | 9.898 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0300 | 0.0470 | 0.0571 | 0.0539 | 0.0699 | 0.1055 |
| 4 | lapply+pmin.int | 0.4011 | 0.6629 | 0.6841 | 0.6975 | 0.7253 | 2.1869 |
| 2 | apply+min | 0.3977 | 0.5884 | 0.8893 | 0.8061 | 0.8702 | 12.4325 |
| 3 | lapply+pmin | 0.5039 | 0.5805 | 0.8195 | 0.8731 | 0.9077 | 2.1442 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
| 4 | lapply+pmin.int | 13.36 | 14.11 | 11.97 | 12.94 | 10.38 | 20.73 |
| 2 | apply+min | 13.24 | 12.53 | 15.56 | 14.96 | 12.45 | 117.87 |
| 3 | lapply+pmin | 16.78 | 12.36 | 14.34 | 16.20 | 12.99 | 20.33 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on integer+100x100 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 24.64 | 38.30 | 50.60 | 48.70 | 59.86 | 113.2 |
| rowMins | 30.03 | 46.97 | 57.15 | 53.89 | 69.87 | 105.5 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| rowMins | 1.219 | 1.226 | 1.129 | 1.107 | 1.167 | 0.932 |
| Figure: Benchmarking of colMins() and rowMins() on integer+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 655508 35.1 1168576 62.5 1168576 62.5
Vcells 12133706 92.6 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655502 35.1 1168576 62.5 1168576 62.5
Vcells 12138813 92.7 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0181 | 0.0329 | 0.0457 | 0.0470 | 0.0581 | 0.0678 |
| 2 | apply+min | 0.2364 | 0.4127 | 0.5263 | 0.4941 | 0.5366 | 3.8634 |
| 4 | lapply+pmin.int | 2.0680 | 3.1077 | 3.3700 | 3.4894 | 3.8203 | 7.3788 |
| 3 | lapply+pmin | 2.8814 | 4.7134 | 5.1891 | 5.3114 | 5.8492 | 9.2304 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.00 | 1.00 | 1.00 | 1.00 | 1.000 | 1.00 |
| 2 | apply+min | 13.06 | 12.54 | 11.52 | 10.52 | 9.232 | 57.02 |
| 4 | lapply+pmin.int | 114.29 | 94.42 | 73.79 | 74.30 | 65.721 | 108.91 |
| 3 | lapply+pmin | 159.25 | 143.20 | 113.62 | 113.09 | 100.624 | 136.24 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0362 | 0.0566 | 0.0661 | 0.0654 | 0.0781 | 0.0959 |
| 2 | apply+min | 0.2367 | 0.4109 | 0.5043 | 0.4887 | 0.5676 | 1.2603 |
| 4 | lapply+pmin.int | 1.9094 | 2.1394 | 3.2388 | 3.3553 | 3.6782 | 10.5608 |
| 3 | lapply+pmin | 2.8698 | 4.2127 | 5.6684 | 5.0835 | 5.4690 | 67.6880 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 |
| 2 | apply+min | 6.543 | 7.262 | 7.631 | 7.468 | 7.263 | 13.15 |
| 4 | lapply+pmin.int | 52.766 | 37.806 | 49.015 | 51.270 | 47.069 | 110.18 |
| 3 | lapply+pmin | 79.308 | 74.445 | 85.783 | 77.678 | 69.984 | 706.16 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on integer+1000x10 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 18.09 | 32.91 | 45.67 | 46.97 | 58.13 | 67.75 |
| rowMins | 36.19 | 56.59 | 66.08 | 65.44 | 78.15 | 95.85 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| rowMins | 2 | 1.719 | 1.447 | 1.393 | 1.344 | 1.415 |
| Figure: Benchmarking of colMins() and rowMins() on integer+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 655550 35.1 1168576 62.5 1168576 62.5
Vcells 12134396 92.6 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655544 35.1 1168576 62.5 1168576 62.5
Vcells 12139503 92.7 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0539 | 0.0616 | 0.0739 | 0.0747 | 0.0824 | 0.1201 |
| 4 | lapply+pmin.int | 0.2267 | 0.2366 | 0.2919 | 0.2652 | 0.3424 | 0.4431 |
| 3 | lapply+pmin | 0.2483 | 0.2589 | 0.3232 | 0.2955 | 0.3763 | 0.4874 |
| 2 | apply+min | 1.9413 | 2.1344 | 2.9921 | 2.9676 | 3.6507 | 7.0986 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 4.207 | 3.841 | 3.949 | 3.551 | 4.157 | 3.689 |
| 3 | lapply+pmin | 4.607 | 4.203 | 4.372 | 3.956 | 4.568 | 4.058 |
| 2 | apply+min | 36.021 | 34.653 | 40.469 | 39.737 | 44.315 | 59.102 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0581 | 0.0730 | 0.0855 | 0.0882 | 0.0962 | 0.1032 |
| 4 | lapply+pmin.int | 0.3876 | 0.4233 | 0.4459 | 0.4311 | 0.4469 | 1.5494 |
| 3 | lapply+pmin | 0.4288 | 0.4573 | 0.4815 | 0.4700 | 0.4877 | 1.3508 |
| 2 | apply+min | 3.3660 | 3.5418 | 4.2500 | 3.6241 | 3.7377 | 44.0125 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 |
| 4 | lapply+pmin.int | 6.669 | 5.802 | 5.216 | 4.891 | 4.644 | 15.02 |
| 3 | lapply+pmin | 7.377 | 6.269 | 5.632 | 5.332 | 5.068 | 13.09 |
| 2 | apply+min | 57.906 | 48.551 | 49.710 | 41.111 | 38.838 | 426.61 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on integer+10x1000 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 53.89 | 61.59 | 73.94 | 74.68 | 82.38 | 120.1 |
| rowMins | 58.13 | 72.95 | 85.50 | 88.16 | 96.24 | 103.2 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1.000 | 1.000 | 1.000 | 1.00 | 1.000 | 1.000 |
| rowMins | 1.079 | 1.184 | 1.156 | 1.18 | 1.168 | 0.859 |
| Figure: Benchmarking of colMins() and rowMins() on integer+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 655583 35.1 1168576 62.5 1168576 62.5
Vcells 12134853 92.6 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655577 35.1 1168576 62.5 1168576 62.5
Vcells 12184960 93.0 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.221 | 0.2766 | 0.3471 | 0.3257 | 0.3528 | 3.235 |
| 4 | lapply+pmin.int | 2.054 | 3.0619 | 3.4148 | 3.7483 | 3.9181 | 4.337 |
| 3 | lapply+pmin | 2.192 | 3.0742 | 3.7925 | 3.9879 | 4.1687 | 17.319 |
| 2 | apply+min | 3.616 | 4.8381 | 6.2682 | 6.4539 | 6.9376 | 19.813 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.000 | 1.00 | 1.000 | 1.00 | 1.00 | 1.000 |
| 4 | lapply+pmin.int | 9.296 | 11.07 | 9.838 | 11.51 | 11.11 | 1.341 |
| 3 | lapply+pmin | 9.920 | 11.11 | 10.927 | 12.25 | 11.82 | 5.354 |
| 2 | apply+min | 16.364 | 17.49 | 18.059 | 19.82 | 19.66 | 6.125 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.2737 | 0.3467 | 0.3881 | 0.3811 | 0.4294 | 0.5232 |
| 4 | lapply+pmin.int | 2.4160 | 3.0286 | 3.6768 | 3.8026 | 3.9254 | 16.4957 |
| 3 | lapply+pmin | 2.5519 | 3.7822 | 3.9756 | 4.0316 | 4.1800 | 17.2432 |
| 2 | apply+min | 3.8530 | 6.6281 | 7.4773 | 7.0289 | 7.5060 | 32.6372 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 |
| 4 | lapply+pmin.int | 8.827 | 8.737 | 9.474 | 9.978 | 9.141 | 31.53 |
| 3 | lapply+pmin | 9.323 | 10.911 | 10.244 | 10.579 | 9.734 | 32.96 |
| 2 | apply+min | 14.077 | 19.120 | 19.267 | 18.443 | 17.480 | 62.39 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on integer+100x1000 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 221.0 | 276.6 | 347.1 | 325.7 | 352.8 | 3234.8 |
| rowMins | 273.7 | 346.7 | 388.1 | 381.1 | 429.4 | 523.2 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1.000 | 1.000 | 1.000 | 1.00 | 1.000 | 1.0000 |
| rowMins | 1.239 | 1.253 | 1.118 | 1.17 | 1.217 | 0.1617 |
| Figure: Benchmarking of colMins() and rowMins() on integer+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 655618 35.1 1168576 62.5 1168576 62.5
Vcells 12135397 92.6 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655612 35.1 1168576 62.5 1168576 62.5
Vcells 12185504 93.0 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.1497 | 0.1963 | 0.2475 | 0.2604 | 0.2822 | 0.390 |
| 2 | apply+min | 2.0195 | 2.1523 | 3.1422 | 3.1547 | 3.7689 | 4.508 |
| 4 | lapply+pmin.int | 4.0235 | 4.9024 | 6.3955 | 6.7523 | 7.0052 | 16.811 |
| 3 | lapply+pmin | 5.0972 | 6.7398 | 8.6340 | 8.5308 | 8.8566 | 34.428 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
| 2 | apply+min | 13.49 | 10.96 | 12.70 | 12.11 | 13.36 | 11.56 |
| 4 | lapply+pmin.int | 26.87 | 24.97 | 25.84 | 25.93 | 24.83 | 43.11 |
| 3 | lapply+pmin | 34.04 | 34.33 | 34.88 | 32.76 | 31.39 | 88.29 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.2267 | 0.2635 | 0.2854 | 0.2745 | 0.2897 | 0.4596 |
| 2 | apply+min | 2.1111 | 3.0076 | 3.4112 | 3.1520 | 3.9537 | 10.2521 |
| 4 | lapply+pmin.int | 4.0039 | 4.2514 | 5.5956 | 4.4822 | 6.6805 | 18.4520 |
| 3 | lapply+pmin | 4.9786 | 5.3768 | 6.7722 | 5.7978 | 8.2282 | 19.1942 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
| 2 | apply+min | 9.311 | 11.41 | 11.95 | 11.48 | 13.65 | 22.30 |
| 4 | lapply+pmin.int | 17.659 | 16.13 | 19.61 | 16.33 | 23.06 | 40.14 |
| 3 | lapply+pmin | 21.957 | 20.41 | 23.73 | 21.12 | 28.40 | 41.76 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on integer+1000x100 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 149.7 | 196.3 | 247.5 | 260.4 | 282.2 | 390.0 |
| rowMins | 226.7 | 263.5 | 285.4 | 274.5 | 289.7 | 459.6 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| rowMins | 1.514 | 1.342 | 1.153 | 1.054 | 1.027 | 1.179 |
| Figure: Benchmarking of colMins() and rowMins() on integer+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100,
+ +100), naProb = 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 (naProb > 0)
+ X[sample(n, size = naProb * 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)> X <- data[["10x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655668 35.1 1168576 62.5 1168576 62.5
Vcells 12251116 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655653 35.1 1168576 62.5 1168576 62.5
Vcells 12251308 93.5 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0031 | 0.0046 | 0.0058 | 0.0058 | 0.0065 | 0.0200 |
| 4 | lapply+pmin.int | 0.0281 | 0.0304 | 0.0320 | 0.0316 | 0.0339 | 0.0373 |
| 3 | lapply+pmin | 0.0420 | 0.0466 | 0.0502 | 0.0489 | 0.0510 | 0.1332 |
| 2 | apply+min | 0.0577 | 0.0608 | 0.0647 | 0.0635 | 0.0662 | 0.1417 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 9.124 | 6.583 | 5.508 | 5.465 | 5.176 | 1.865 |
| 3 | lapply+pmin | 13.624 | 10.082 | 8.649 | 8.464 | 7.793 | 6.653 |
| 2 | apply+min | 18.748 | 13.165 | 11.134 | 10.997 | 10.117 | 7.077 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0031 | 0.0039 | 0.0062 | 0.0058 | 0.0069 | 0.0593 |
| 4 | lapply+pmin.int | 0.0273 | 0.0308 | 0.0341 | 0.0321 | 0.0339 | 0.1205 |
| 3 | lapply+pmin | 0.0431 | 0.0472 | 0.0498 | 0.0489 | 0.0516 | 0.0959 |
| 2 | apply+min | 0.0566 | 0.0612 | 0.0641 | 0.0631 | 0.0654 | 0.1420 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 8.874 | 7.997 | 5.468 | 5.566 | 4.888 | 2.033 |
| 3 | lapply+pmin | 13.998 | 12.246 | 7.971 | 8.466 | 7.443 | 1.617 |
| 2 | apply+min | 18.373 | 15.894 | 10.272 | 10.932 | 9.443 | 2.396 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on double+10x10 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() on double+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 3.08 | 3.851 | 6.245 | 5.775 | 6.931 | 59.28 |
| 1 | colMins | 3.08 | 4.620 | 5.810 | 5.776 | 6.545 | 20.02 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 1 | 1.0 | 1.0000 | 1 | 1.0000 | 1.0000 |
| 1 | colMins | 1 | 1.2 | 0.9303 | 1 | 0.9444 | 0.3377 |
| Figure: Benchmarking of colMins() and rowMins() on double+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 655689 35.1 1168576 62.5 1168576 62.5
Vcells 12251904 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655683 35.1 1168576 62.5 1168576 62.5
Vcells 12262011 93.6 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0393 | 0.0593 | 0.0763 | 0.0776 | 0.0878 | 0.2479 |
| 4 | lapply+pmin.int | 0.4311 | 0.4916 | 0.6419 | 0.6968 | 0.7174 | 0.8504 |
| 2 | apply+min | 0.4235 | 0.5443 | 0.8142 | 0.7509 | 0.8321 | 11.6872 |
| 3 | lapply+pmin | 0.5270 | 0.5974 | 0.8020 | 0.8636 | 0.8919 | 1.2103 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.00 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 10.98 | 8.292 | 8.412 | 8.983 | 8.173 | 3.430 |
| 2 | apply+min | 10.78 | 9.182 | 10.671 | 9.680 | 9.480 | 47.143 |
| 3 | lapply+pmin | 13.42 | 10.078 | 10.511 | 11.134 | 10.162 | 4.882 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0427 | 0.0679 | 0.0798 | 0.0795 | 0.0939 | 0.1047 |
| 4 | lapply+pmin.int | 0.4627 | 0.7305 | 0.6951 | 0.7451 | 0.7711 | 0.8246 |
| 2 | apply+min | 0.4131 | 0.4839 | 0.8004 | 0.7659 | 0.8504 | 10.6825 |
| 3 | lapply+pmin | 0.5578 | 0.5834 | 0.8222 | 0.9110 | 0.9406 | 1.1506 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 10.829 | 10.751 | 8.707 | 9.373 | 8.209 | 7.875 |
| 2 | apply+min | 9.666 | 7.122 | 10.025 | 9.634 | 9.053 | 102.021 |
| 3 | lapply+pmin | 13.054 | 8.586 | 10.299 | 11.460 | 10.014 | 10.989 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on double+100x100 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 39.27 | 59.28 | 76.30 | 77.57 | 87.77 | 247.9 |
| rowMins | 42.73 | 67.95 | 79.83 | 79.49 | 93.93 | 104.7 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 | 1.0000 |
| rowMins | 1.088 | 1.146 | 1.046 | 1.025 | 1.07 | 0.4224 |
| Figure: Benchmarking of colMins() and rowMins() on double+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 655715 35.1 1168576 62.5 1168576 62.5
Vcells 12252822 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655718 35.1 1168576 62.5 1168576 62.5
Vcells 12262944 93.6 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0354 | 0.0549 | 0.0676 | 0.0679 | 0.0835 | 0.0982 |
| 2 | apply+min | 0.2552 | 0.3569 | 0.4184 | 0.4129 | 0.4997 | 0.7087 |
| 4 | lapply+pmin.int | 2.2443 | 2.3773 | 3.1566 | 2.6306 | 3.7127 | 8.1183 |
| 3 | lapply+pmin | 3.1043 | 3.3972 | 4.3337 | 3.6086 | 5.3497 | 10.8145 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 |
| 2 | apply+min | 7.207 | 6.505 | 6.185 | 6.076 | 5.981 | 7.22 |
| 4 | lapply+pmin.int | 63.369 | 43.336 | 46.667 | 38.716 | 44.444 | 82.70 |
| 3 | lapply+pmin | 87.652 | 61.929 | 64.069 | 53.110 | 64.041 | 110.17 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0404 | 0.0464 | 0.0672 | 0.0708 | 0.0762 | 0.1028 |
| 2 | apply+min | 0.2521 | 0.3532 | 0.4205 | 0.4202 | 0.4639 | 0.6113 |
| 4 | lapply+pmin.int | 2.0476 | 2.1904 | 2.6553 | 2.2645 | 3.2981 | 7.1324 |
| 3 | lapply+pmin | 2.9911 | 3.1845 | 4.1502 | 3.3037 | 5.0650 | 15.3643 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 2 | apply+min | 6.238 | 7.614 | 6.254 | 5.932 | 6.086 | 5.947 |
| 4 | lapply+pmin.int | 50.656 | 47.219 | 39.492 | 31.970 | 43.270 | 69.392 |
| 3 | lapply+pmin | 73.999 | 68.651 | 61.725 | 46.641 | 66.451 | 149.481 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on double+1000x10 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 35.42 | 54.86 | 67.64 | 67.95 | 83.54 | 98.16 |
| rowMins | 40.42 | 46.39 | 67.24 | 70.83 | 76.22 | 102.78 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1.000 | 1.0000 | 1.000 | 1.000 | 1.0000 | 1.000 |
| rowMins | 1.141 | 0.8456 | 0.994 | 1.042 | 0.9124 | 1.047 |
| Figure: Benchmarking of colMins() and rowMins() on double+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 655766 35.1 1168576 62.5 1168576 62.5
Vcells 12252867 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655760 35.1 1168576 62.5 1168576 62.5
Vcells 12262974 93.6 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.0658 | 0.0914 | 0.1022 | 0.1009 | 0.1172 | 0.1578 |
| 4 | lapply+pmin.int | 0.2849 | 0.3016 | 0.3859 | 0.4196 | 0.4371 | 0.4835 |
| 3 | lapply+pmin | 0.3006 | 0.3411 | 0.4494 | 0.4587 | 0.4833 | 2.1804 |
| 2 | apply+min | 2.0456 | 2.7482 | 3.6310 | 3.7620 | 4.0547 | 7.9782 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 4.327 | 3.299 | 3.777 | 4.160 | 3.729 | 3.063 |
| 3 | lapply+pmin | 4.567 | 3.731 | 4.398 | 4.548 | 4.123 | 13.815 |
| 2 | apply+min | 31.076 | 30.059 | 35.532 | 37.299 | 34.591 | 50.548 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on double+10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times. |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 0.0639 | 0.0843 | 0.0985 | 0.0993 | 0.1155 | 0.1351 |
| 4 | lapply+pmin.int | 0.3234 | 0.3443 | 0.4455 | 0.4868 | 0.5029 | 0.6860 |
| 3 | lapply+pmin | 0.3430 | 0.3703 | 0.4596 | 0.5149 | 0.5416 | 0.5747 |
| 2 | apply+min | 2.0730 | 2.2058 | 3.1868 | 3.5198 | 3.8284 | 7.4816 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 5.060 | 4.084 | 4.524 | 4.901 | 4.355 | 5.077 |
| 3 | lapply+pmin | 5.367 | 4.393 | 4.667 | 5.184 | 4.690 | 4.253 |
| 2 | apply+min | 32.439 | 26.164 | 32.360 | 35.440 | 33.150 | 55.370 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on double+10x1000 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() on double+10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 63.90 | 84.31 | 98.48 | 99.32 | 115.5 | 135.1 |
| 1 | colMins | 65.83 | 91.43 | 102.19 | 100.86 | 117.2 | 157.8 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 1.00 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 1 | colMins | 1.03 | 1.085 | 1.038 | 1.016 | 1.015 | 1.168 |
| Figure: Benchmarking of colMins() and rowMins() on double+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 655799 35.1 1168576 62.5 1168576 62.5
Vcells 12253985 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655793 35.1 1168576 62.5 1168576 62.5
Vcells 12354092 94.3 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.3803 | 0.5996 | 0.6717 | 0.6764 | 0.6979 | 2.208 |
| 4 | lapply+pmin.int | 2.8925 | 3.8638 | 4.4952 | 4.7116 | 5.0256 | 7.877 |
| 3 | lapply+pmin | 3.0203 | 4.7188 | 5.2304 | 5.1565 | 5.3218 | 19.556 |
| 2 | apply+min | 3.8934 | 5.4810 | 6.9604 | 6.9871 | 7.3994 | 22.820 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 4 | lapply+pmin.int | 7.605 | 6.444 | 6.692 | 6.966 | 7.201 | 3.568 |
| 3 | lapply+pmin | 7.941 | 7.870 | 7.787 | 7.624 | 7.625 | 8.858 |
| 2 | apply+min | 10.237 | 9.142 | 10.363 | 10.330 | 10.602 | 10.336 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.4131 | 0.6596 | 0.686 | 0.7185 | 0.7376 | 1.124 |
| 4 | lapply+pmin.int | 3.0954 | 4.6239 | 4.682 | 4.6999 | 4.7848 | 18.997 |
| 3 | lapply+pmin | 3.1793 | 4.7567 | 4.839 | 4.9186 | 5.0002 | 15.284 |
| 2 | apply+min | 4.1367 | 7.2660 | 7.810 | 7.7243 | 8.4047 | 23.581 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 |
| 4 | lapply+pmin.int | 7.494 | 7.010 | 6.825 | 6.541 | 6.487 | 16.91 |
| 3 | lapply+pmin | 7.697 | 7.211 | 7.054 | 6.845 | 6.779 | 13.60 |
| 2 | apply+min | 10.015 | 11.015 | 11.385 | 10.750 | 11.395 | 20.99 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on double+100x1000 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 |
|---|---|---|---|---|---|---|
| colMins | 380.3 | 599.6 | 671.7 | 676.4 | 697.9 | 2208 |
| rowMins | 413.1 | 659.6 | 686.0 | 718.5 | 737.6 | 1124 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colMins | 1.000 | 1.0 | 1.000 | 1.000 | 1.000 | 1.000 |
| rowMins | 1.086 | 1.1 | 1.021 | 1.062 | 1.057 | 0.509 |
| Figure: Benchmarking of colMins() and rowMins() on double+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 655834 35.1 1168576 62.5 1168576 62.5
Vcells 12254008 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colMins = colMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 2L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(nrow(X)), function(i) X[i,
+ ])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(nrow(X)), function(i) X[i, ])), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 655828 35.1 1168576 62.5 1168576 62.5
Vcells 12354115 94.3 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowMins = rowMins(X, na.rm = FALSE), `apply+min` = apply(X, MARGIN = 1L,
+ FUN = min, na.rm = FALSE), `lapply+pmin` = do.call(pmin, lapply(seq_len(ncol(X)), function(i) X[,
+ i])), `lapply+pmin.int` = do.call(pmin.int, lapply(seq_len(ncol(X)), function(i) X[, i])), unit = "ms")Table: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.3349 | 0.4369 | 0.5656 | 0.6015 | 0.6563 | 0.9501 |
| 2 | apply+min | 2.2170 | 3.2675 | 3.6508 | 3.7656 | 4.1585 | 5.7058 |
| 4 | lapply+pmin.int | 4.6610 | 5.2284 | 7.4279 | 7.6356 | 7.9836 | 23.7332 |
| 3 | lapply+pmin | 5.7481 | 6.7380 | 9.2377 | 9.3430 | 9.7035 | 26.7443 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMins | 1.00 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 2 | apply+min | 6.62 | 7.478 | 6.455 | 6.261 | 6.336 | 6.006 |
| 4 | lapply+pmin.int | 13.92 | 11.966 | 13.133 | 12.694 | 12.164 | 24.980 |
| 3 | lapply+pmin | 17.16 | 15.421 | 16.333 | 15.533 | 14.784 | 28.150 |
| Table: Benchmarking of rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() 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 | 0.3599 | 0.4188 | 0.5541 | 0.5711 | 0.6927 | 0.8176 |
| 2 | apply+min | 2.4348 | 4.3559 | 4.9334 | 4.8645 | 5.6482 | 11.7107 |
| 4 | lapply+pmin.int | 4.7372 | 5.1241 | 7.3061 | 7.3164 | 7.9454 | 20.2859 |
| 3 | lapply+pmin | 5.8690 | 6.1843 | 8.1598 | 7.7331 | 9.4395 | 21.6017 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMins | 1.000 | 1.00 | 1.000 | 1.000 | 1.000 | 1.00 |
| 2 | apply+min | 6.765 | 10.40 | 8.904 | 8.518 | 8.154 | 14.32 |
| 4 | lapply+pmin.int | 13.162 | 12.23 | 13.186 | 12.812 | 11.470 | 24.81 |
| 3 | lapply+pmin | 16.306 | 14.77 | 14.727 | 13.541 | 13.627 | 26.42 |
| Figure: Benchmarking of colMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on double+1000x100 data as well as rowMins(), apply+min(), lapply+pmin() and lapply+pmin.int() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colMins() and rowMins() 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 | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 359.9 | 418.8 | 554.1 | 571.1 | 692.7 | 817.6 |
| 1 | colMins | 334.9 | 436.9 | 565.6 | 601.5 | 656.3 | 950.1 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMins | 1.0000 | 1.000 | 1.000 | 1.000 | 1.0000 | 1.000 |
| 1 | colMins | 0.9305 | 1.043 | 1.021 | 1.053 | 0.9475 | 1.162 |
| Figure: Benchmarking of colMins() and rowMins() on double+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

R Under development (unstable) (2015-02-27 r67909)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] markdown_0.7.7 microbenchmark_1.4-2 matrixStats_0.14.0-9000
[4] ggplot2_1.0.0 knitr_1.9.3 R.devices_2.13.0
[7] R.utils_2.0.0 R.oo_1.19.0 R.methodsS3_1.7.0
loaded via a namespace (and not attached):
[1] Rcpp_0.11.4 splines_3.2.0 MASS_7.3-39
[4] munsell_0.4.2 lattice_0.20-30 colorspace_1.2-4
[7] R.cache_0.11.1-9000 multcomp_1.3-9 stringr_0.6.2
[10] plyr_1.8.1 tools_3.2.0 grid_3.2.0
[13] gtable_0.1.2 TH.data_1.0-6 survival_2.38-1
[16] digest_0.6.8 R.rsp_0.20.0 reshape2_1.4.1
[19] formatR_1.0.3 base64enc_0.1-3 mime_0.2.1
[22] evaluate_0.5.7 labeling_0.3 sandwich_2.3-2
[25] scales_0.2.4 mvtnorm_1.0-2 zoo_1.7-12
[28] Cairo_1.5-6 proto_0.3-10 Total processing time was 1.01 mins.
To reproduce this report, do:
html <- matrixStats:::benchmark('colMins')Copyright Henrik Bengtsson. Last updated on 2015-03-02 17:10:30 (-0800 UTC). Powered by RSP.
<script> var link = document.createElement('link'); link.rel = 'icon'; link.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAADFBMVEX9/v0AAP/9/v3//wBEQjoBAAAABHRSTlP//wD//gy7CwAAAGJJREFUOI3N0rESwCAIA9Ag///PXdoiBk0HhmbNO49DMETQCexNCSyFgdlGoO5DYOr9ThLgPosA7osIQP0sHuDOog8UI/ALa988wzdwXJRctf4s+d36YPTJ6aMd8ux3+QO4ABTtB85yDAh9AAAAAElFTkSuQmCC" document.getElementsByTagName('head')[0].appendChild(link); </script>[Benchmark reports](Benchmark reports)