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), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)
> X <- data[["10x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3156357 168.6 5709258 305.0 5709258 305.0
Vcells 6190405 47.3 22267496 169.9 56666022 432.4
> 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 3154881 168.5 5709258 305.0 5709258 305.0
Vcells 6186509 47.2 22267496 169.9 56666022 432.4
> 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.001137 | 0.0013985 | 0.0017979 | 0.0017215 | 0.0018860 | 0.012950 |
4 | lapply+pmin.int | 0.010715 | 0.0113850 | 0.0128012 | 0.0119710 | 0.0125560 | 0.065509 |
3 | lapply+pmin | 0.017601 | 0.0184710 | 0.0192623 | 0.0189725 | 0.0197230 | 0.033257 |
2 | apply+min | 0.019919 | 0.0209500 | 0.0223913 | 0.0217425 | 0.0224085 | 0.073963 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 9.423923 | 8.140865 | 7.120033 | 6.953819 | 6.657476 | 5.058610 |
3 | lapply+pmin | 15.480211 | 13.207723 | 10.713647 | 11.020912 | 10.457582 | 2.568108 |
2 | apply+min | 17.518909 | 14.980336 | 12.453997 | 12.629974 | 11.881495 | 5.711429 |
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.001132 | 0.0014365 | 0.0018099 | 0.001780 | 0.0019550 | 0.011586 |
4 | lapply+pmin.int | 0.010509 | 0.0112450 | 0.0117930 | 0.011543 | 0.0120905 | 0.017538 |
3 | lapply+pmin | 0.017708 | 0.0182300 | 0.0197311 | 0.018909 | 0.0195320 | 0.077664 |
2 | apply+min | 0.020047 | 0.0210240 | 0.0222480 | 0.021490 | 0.0220250 | 0.074020 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 9.283569 | 7.828054 | 6.515879 | 6.484832 | 6.184399 | 1.513723 |
3 | lapply+pmin | 15.643109 | 12.690567 | 10.901883 | 10.623034 | 9.990793 | 6.703263 |
2 | apply+min | 17.709364 | 14.635573 | 12.292522 | 12.073034 | 11.265985 | 6.388745 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.137 | 1.3985 | 1.79792 | 1.7215 | 1.886 | 12.950 |
2 | rowMins | 1.132 | 1.4365 | 1.80988 | 1.7800 | 1.955 | 11.586 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMins | 0.9956025 | 1.027172 | 1.006652 | 1.033982 | 1.036585 | 0.8946718 |
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 3153457 168.5 5709258 305.0 5709258 305.0
Vcells 5803261 44.3 22267496 169.9 56666022 432.4
> 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 3153448 168.5 5709258 305.0 5709258 305.0
Vcells 5808363 44.4 22267496 169.9 56666022 432.4
> 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.014469 | 0.0151180 | 0.0162750 | 0.015522 | 0.0157540 | 0.069830 |
4 | lapply+pmin.int | 0.134559 | 0.1368985 | 0.1418128 | 0.138374 | 0.1398730 | 0.237444 |
2 | apply+min | 0.142409 | 0.1445910 | 0.1481664 | 0.145789 | 0.1475355 | 0.231249 |
3 | lapply+pmin | 0.181965 | 0.1844315 | 0.1893252 | 0.185836 | 0.1884170 | 0.278959 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 9.299813 | 9.055331 | 8.713551 | 8.914702 | 8.878571 | 3.400315 |
2 | apply+min | 9.842353 | 9.564162 | 9.103942 | 9.392411 | 9.364955 | 3.311600 |
3 | lapply+pmin | 12.576197 | 12.199464 | 11.632908 | 11.972426 | 11.959947 | 3.994830 |
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.014911 | 0.0156800 | 0.0163419 | 0.0161715 | 0.0166915 | 0.027966 |
4 | lapply+pmin.int | 0.118037 | 0.1215355 | 0.1244228 | 0.1228295 | 0.1240965 | 0.190294 |
2 | apply+min | 0.142605 | 0.1457455 | 0.1503770 | 0.1470990 | 0.1496940 | 0.288713 |
3 | lapply+pmin | 0.164555 | 0.1694915 | 0.1738016 | 0.1709685 | 0.1727430 | 0.256241 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 7.916102 | 7.750989 | 7.613733 | 7.595430 | 7.434712 | 6.804477 |
2 | apply+min | 9.563745 | 9.294994 | 9.201934 | 9.096188 | 8.968277 | 10.323714 |
3 | lapply+pmin | 11.035813 | 10.809407 | 10.635344 | 10.572210 | 10.349160 | 9.162590 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 14.469 | 15.118 | 16.27497 | 15.5220 | 15.7540 | 69.830 |
2 | rowMins | 14.911 | 15.680 | 16.34189 | 16.1715 | 16.6915 | 27.966 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMins | 1.030548 | 1.037174 | 1.004112 | 1.041844 | 1.059509 | 0.4004869 |
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 3154226 168.5 5709258 305.0 5709258 305.0
Vcells 5807057 44.4 22267496 169.9 56666022 432.4
> 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 3154214 168.5 5709258 305.0 5709258 305.0
Vcells 5812154 44.4 22267496 169.9 56666022 432.4
> 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.011608 | 0.0124610 | 0.0141042 | 0.0136045 | 0.014834 | 0.023159 |
2 | apply+min | 0.070636 | 0.0768480 | 0.0859544 | 0.0812535 | 0.088094 | 0.213670 |
4 | lapply+pmin.int | 0.846861 | 0.8747245 | 0.9245479 | 0.9004855 | 0.973005 | 1.177411 |
3 | lapply+pmin | 1.278641 | 1.3034650 | 1.4603406 | 1.3286910 | 1.409936 | 6.720430 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | apply+min | 6.085114 | 6.167081 | 6.094258 | 5.972546 | 5.938654 | 9.226219 |
4 | lapply+pmin.int | 72.954945 | 70.196975 | 65.551389 | 66.190268 | 65.592895 | 50.840321 |
3 | lapply+pmin | 110.151706 | 104.603563 | 103.539635 | 97.665552 | 95.047627 | 290.186537 |
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.013066 | 0.0144340 | 0.0165290 | 0.015474 | 0.0168030 | 0.034570 |
2 | apply+min | 0.070142 | 0.0762545 | 0.0871575 | 0.081552 | 0.0881160 | 0.175111 |
4 | lapply+pmin.int | 0.824782 | 0.8488425 | 0.9462911 | 0.896508 | 0.9521905 | 1.999018 |
3 | lapply+pmin | 1.253736 | 1.2999775 | 1.5203883 | 1.369052 | 1.4662535 | 6.795446 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 |
2 | apply+min | 5.368284 | 5.282978 | 5.272996 | 5.27026 | 5.244064 | 5.065404 |
4 | lapply+pmin.int | 63.124292 | 58.808542 | 57.250251 | 57.93641 | 56.667887 | 57.825224 |
3 | lapply+pmin | 95.954079 | 90.063565 | 91.982914 | 88.47431 | 87.261412 | 196.570610 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 11.608 | 12.461 | 14.10417 | 13.6045 | 14.834 | 23.159 |
2 | rowMins | 13.066 | 14.434 | 16.52903 | 15.4740 | 16.803 | 34.570 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowMins | 1.125603 | 1.158334 | 1.171925 | 1.137418 | 1.132736 | 1.492724 |
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 3154445 168.5 5709258 305.0 5709258 305.0
Vcells 5807956 44.4 22267496 169.9 56666022 432.4
> 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 3154436 168.5 5709258 305.0 5709258 305.0
Vcells 5813058 44.4 22267496 169.9 56666022 432.4
> 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.028948 | 0.0304065 | 0.0318185 | 0.0311845 | 0.0319520 | 0.061127 |
4 | lapply+pmin.int | 0.073581 | 0.0762075 | 0.0821658 | 0.0789430 | 0.0813635 | 0.263396 |
3 | lapply+pmin | 0.080234 | 0.0850440 | 0.0892420 | 0.0874505 | 0.0896270 | 0.198933 |
2 | apply+min | 0.812720 | 0.8320325 | 0.8478344 | 0.8389590 | 0.8499570 | 1.175260 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 2.541834 | 2.506290 | 2.582326 | 2.531482 | 2.546429 | 4.308996 |
3 | lapply+pmin | 2.771660 | 2.796902 | 2.804717 | 2.804294 | 2.805051 | 3.254421 |
2 | apply+min | 28.075169 | 27.363639 | 26.645931 | 26.903077 | 26.601058 | 19.226528 |
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.028729 | 0.0303495 | 0.0320850 | 0.0311785 | 0.032475 | 0.042210 |
4 | lapply+pmin.int | 0.058324 | 0.0606570 | 0.0675510 | 0.0620690 | 0.064542 | 0.355443 |
3 | lapply+pmin | 0.066075 | 0.0691155 | 0.0738142 | 0.0711160 | 0.075178 | 0.146424 |
2 | apply+min | 0.800509 | 0.8296635 | 0.8533022 | 0.8445705 | 0.863575 | 1.011454 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 2.030144 | 1.998616 | 2.105380 | 1.990763 | 1.987437 | 8.420824 |
3 | lapply+pmin | 2.299941 | 2.277319 | 2.300586 | 2.280931 | 2.314950 | 3.468941 |
2 | apply+min | 27.864144 | 27.336974 | 26.595084 | 27.088234 | 26.591994 | 23.962426 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowMins | 28.729 | 30.3495 | 32.08496 | 31.1785 | 32.475 | 42.210 |
1 | colMins | 28.948 | 30.4065 | 31.81853 | 31.1845 | 31.952 | 61.127 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowMins | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.0000000 | 1.000000 |
1 | colMins | 1.007623 | 1.001878 | 0.9916961 | 1.000192 | 0.9838953 | 1.448164 |
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 3154665 168.5 5709258 305.0 5709258 305.0
Vcells 5808555 44.4 22267496 169.9 56666022 432.4
> 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 3154659 168.5 5709258 305.0 5709258 305.0
Vcells 5858662 44.7 22267496 169.9 56666022 432.4
> 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.137467 | 0.1388440 | 0.1483452 | 0.1405780 | 0.1491505 | 0.204836 |
4 | lapply+pmin.int | 0.646598 | 0.6606205 | 0.9469813 | 0.6650970 | 0.6922240 | 12.979119 |
3 | lapply+pmin | 0.696305 | 0.7101410 | 0.7684295 | 0.7199685 | 0.7915285 | 1.242798 |
2 | apply+min | 1.285617 | 1.3025120 | 1.4027658 | 1.3315200 | 1.4251605 | 1.993737 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 4.703660 | 4.758005 | 6.383631 | 4.731160 | 4.641111 | 63.363466 |
3 | lapply+pmin | 5.065252 | 5.114668 | 5.180008 | 5.121488 | 5.306912 | 6.067283 |
2 | apply+min | 9.352186 | 9.381118 | 9.456089 | 9.471752 | 9.555184 | 9.733333 |
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.143332 | 0.1447920 | 0.1552814 | 0.1469605 | 0.156462 | 0.222039 |
4 | lapply+pmin.int | 0.430581 | 0.4410470 | 0.6078231 | 0.4493855 | 0.490686 | 13.700603 |
3 | lapply+pmin | 0.476580 | 0.4866225 | 0.5327844 | 0.4993440 | 0.571511 | 0.690458 |
2 | apply+min | 1.292407 | 1.3138665 | 1.5435058 | 1.3411760 | 1.517270 | 13.054694 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 3.004081 | 3.046073 | 3.914333 | 3.057866 | 3.136135 | 61.703588 |
3 | lapply+pmin | 3.325008 | 3.360838 | 3.431090 | 3.397811 | 3.652714 | 3.109625 |
2 | apply+min | 9.016877 | 9.074165 | 9.940056 | 9.126098 | 9.697367 | 58.794599 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 137.467 | 138.844 | 148.3452 | 140.5780 | 149.1505 | 204.836 |
2 | rowMins | 143.332 | 144.792 | 155.2814 | 146.9605 | 156.4620 | 222.039 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowMins | 1.042665 | 1.042839 | 1.046757 | 1.045402 | 1.049021 | 1.083984 |
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 3154901 168.5 5709258 305.0 5709258 305.0
Vcells 5809365 44.4 22267496 169.9 56666022 432.4
> 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 3154892 168.5 5709258 305.0 5709258 305.0
Vcells 5859467 44.8 22267496 169.9 56666022 432.4
> 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.106332 | 0.1097655 | 0.122284 | 0.1187120 | 0.1327950 | 0.164819 |
2 | apply+min | 0.562735 | 0.6144125 | 1.012706 | 0.6626605 | 0.7702015 | 18.073797 |
4 | lapply+pmin.int | 1.331521 | 1.4357940 | 1.601527 | 1.5567945 | 1.7567050 | 2.141153 |
3 | lapply+pmin | 1.771905 | 1.8920870 | 2.124264 | 2.0742770 | 2.3162400 | 2.882171 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | apply+min | 5.292245 | 5.597501 | 8.281596 | 5.582085 | 5.799929 | 109.65846 |
4 | lapply+pmin.int | 12.522298 | 13.080558 | 13.096789 | 13.114045 | 13.228698 | 12.99094 |
3 | lapply+pmin | 16.663892 | 17.237538 | 17.371572 | 17.473187 | 17.442223 | 17.48689 |
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.115918 | 0.1181715 | 0.1287715 | 0.1230760 | 0.1307515 | 0.187111 |
2 | apply+min | 0.573702 | 0.5953275 | 0.6502067 | 0.6178695 | 0.6577145 | 0.942786 |
4 | lapply+pmin.int | 1.161396 | 1.1881985 | 1.5280927 | 1.2318300 | 1.3160820 | 25.420040 |
3 | lapply+pmin | 1.594454 | 1.6374130 | 1.9188378 | 1.6906105 | 1.7821925 | 17.473094 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | apply+min | 4.949205 | 5.037826 | 5.049308 | 5.020227 | 5.030264 | 5.038646 |
4 | lapply+pmin.int | 10.019117 | 10.054865 | 11.866703 | 10.008694 | 10.065521 | 135.855401 |
3 | lapply+pmin | 13.755016 | 13.856243 | 14.901110 | 13.736313 | 13.630379 | 93.383574 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 106.332 | 109.7655 | 122.2840 | 118.712 | 132.7950 | 164.819 |
2 | rowMins | 115.918 | 118.1715 | 128.7715 | 123.076 | 130.7515 | 187.111 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 |
2 | rowMins | 1.090152 | 1.076581 | 1.053053 | 1.036761 | 0.9846116 | 1.135251 |
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), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)
> X <- data[["10x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3155139 168.6 5709258 305.0 5709258 305.0
Vcells 5925323 45.3 22267496 169.9 56666022 432.4
> 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 3155121 168.6 5709258 305.0 5709258 305.0
Vcells 5925510 45.3 22267496 169.9 56666022 432.4
> 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.001095 | 0.0013365 | 0.0018835 | 0.0017865 | 0.0020025 | 0.011847 |
4 | lapply+pmin.int | 0.010763 | 0.0115325 | 0.0131063 | 0.0118700 | 0.0126725 | 0.050185 |
3 | lapply+pmin | 0.017646 | 0.0185145 | 0.0197134 | 0.0189095 | 0.0199470 | 0.039183 |
2 | apply+min | 0.020384 | 0.0212020 | 0.0227468 | 0.0220345 | 0.0226960 | 0.064985 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 9.829224 | 8.628881 | 6.95864 | 6.644277 | 6.328340 | 4.236093 |
3 | lapply+pmin | 16.115068 | 13.852974 | 10.46658 | 10.584663 | 9.961049 | 3.307420 |
2 | apply+min | 18.615525 | 15.863823 | 12.07713 | 12.333893 | 11.333833 | 5.485355 |
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.001135 | 0.0016145 | 0.0024178 | 0.0019200 | 0.0021890 | 0.013671 |
4 | lapply+pmin.int | 0.010623 | 0.0114705 | 0.0151826 | 0.0121825 | 0.0129675 | 0.049918 |
3 | lapply+pmin | 0.017430 | 0.0187870 | 0.0248658 | 0.0197465 | 0.0214365 | 0.083197 |
2 | apply+min | 0.019789 | 0.0212265 | 0.0290426 | 0.0221185 | 0.0363060 | 0.096060 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 9.359471 | 7.104676 | 6.279528 | 6.345052 | 5.923938 | 3.651379 |
3 | lapply+pmin | 15.356828 | 11.636420 | 10.284524 | 10.284635 | 9.792828 | 6.085656 |
2 | apply+min | 17.435242 | 13.147414 | 12.012036 | 11.520052 | 16.585656 | 7.026553 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.095 | 1.3365 | 1.88346 | 1.7865 | 2.0025 | 11.847 |
2 | rowMins | 1.135 | 1.6145 | 2.41779 | 1.9200 | 2.1890 | 13.671 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowMins | 1.03653 | 1.208006 | 1.283696 | 1.074727 | 1.093134 | 1.153963 |
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 3155356 168.6 5709258 305.0 5709258 305.0
Vcells 5926391 45.3 22267496 169.9 56666022 432.4
> 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 3155347 168.6 5709258 305.0 5709258 305.0
Vcells 5936493 45.3 22267496 169.9 56666022 432.4
> 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.012066 | 0.0131320 | 0.0138258 | 0.0135725 | 0.0139955 | 0.034413 |
4 | lapply+pmin.int | 0.156763 | 0.1594575 | 0.1647156 | 0.1612780 | 0.1640450 | 0.299866 |
2 | apply+min | 0.184231 | 0.1866225 | 0.1910064 | 0.1887515 | 0.1911115 | 0.288866 |
3 | lapply+pmin | 0.204048 | 0.2074110 | 0.2110284 | 0.2095045 | 0.2120060 | 0.252313 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.00000 | 1.00000 | 1.00000 | 1.00000 | 1.00000 | 1.000000 |
4 | lapply+pmin.int | 12.99213 | 12.14267 | 11.91360 | 11.88270 | 11.72127 | 8.713742 |
2 | apply+min | 15.26861 | 14.21128 | 13.81516 | 13.90691 | 13.65521 | 8.394095 |
3 | lapply+pmin | 16.91099 | 15.79432 | 15.26332 | 15.43596 | 15.14815 | 7.331910 |
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.015478 | 0.016610 | 0.0175632 | 0.0171075 | 0.0176155 | 0.030675 |
4 | lapply+pmin.int | 0.119277 | 0.122615 | 0.1282200 | 0.1248255 | 0.1272840 | 0.228531 |
2 | apply+min | 0.142397 | 0.147601 | 0.1542465 | 0.1497790 | 0.1550655 | 0.255778 |
3 | lapply+pmin | 0.165291 | 0.169898 | 0.1757570 | 0.1736065 | 0.1762865 | 0.270137 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 7.706228 | 7.381999 | 7.300498 | 7.296537 | 7.225682 | 7.450073 |
2 | apply+min | 9.199961 | 8.886273 | 8.782376 | 8.755166 | 8.802787 | 8.338321 |
3 | lapply+pmin | 10.679093 | 10.228657 | 10.007121 | 10.147976 | 10.007465 | 8.806422 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 12.066 | 13.132 | 13.82585 | 13.5725 | 13.9955 | 34.413 |
2 | rowMins | 15.478 | 16.610 | 17.56319 | 17.1075 | 17.6155 | 30.675 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMins | 1.282778 | 1.264849 | 1.270315 | 1.260453 | 1.258655 | 0.8913783 |
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 3155582 168.6 5709258 305.0 5709258 305.0
Vcells 5927553 45.3 22267496 169.9 56666022 432.4
> 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 3155573 168.6 5709258 305.0 5709258 305.0
Vcells 5937655 45.4 22267496 169.9 56666022 432.4
> 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.009627 | 0.0110775 | 0.0142640 | 0.0128145 | 0.0171670 | 0.024682 |
2 | apply+min | 0.118891 | 0.1270410 | 0.1435655 | 0.1358925 | 0.1501945 | 0.283164 |
4 | lapply+pmin.int | 0.845375 | 0.9091590 | 0.9673517 | 0.9531245 | 1.0085925 | 1.313164 |
3 | lapply+pmin | 1.285765 | 1.3439685 | 1.5260650 | 1.4110785 | 1.4862160 | 7.050950 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.00000 | 1.00000 | 1.00000 | 1.00000 | 1.000000 | 1.00000 |
2 | apply+min | 12.34975 | 11.46838 | 10.06489 | 10.60459 | 8.749024 | 11.47249 |
4 | lapply+pmin.int | 87.81292 | 82.07258 | 67.81775 | 74.37859 | 58.751820 | 53.20331 |
3 | lapply+pmin | 133.55822 | 121.32417 | 106.98725 | 110.11577 | 86.574008 | 285.67174 |
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.013682 | 0.0149120 | 0.0184035 | 0.0161905 | 0.0206895 | 0.039118 |
2 | apply+min | 0.076174 | 0.0853800 | 0.1044279 | 0.0934185 | 0.1117440 | 0.243824 |
4 | lapply+pmin.int | 0.812497 | 0.8517465 | 0.9095495 | 0.8968730 | 0.9313290 | 1.421450 |
3 | lapply+pmin | 1.252533 | 1.3009360 | 1.4894101 | 1.3448430 | 1.4586115 | 6.843495 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | apply+min | 5.567461 | 5.72559 | 5.674346 | 5.769958 | 5.401001 | 6.233039 |
4 | lapply+pmin.int | 59.384374 | 57.11819 | 49.422583 | 55.395016 | 45.014573 | 36.337492 |
3 | lapply+pmin | 91.546046 | 87.24088 | 80.930720 | 83.063710 | 70.500085 | 174.944910 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 9.627 | 11.0775 | 14.26399 | 12.8145 | 17.1670 | 24.682 |
2 | rowMins | 13.682 | 14.9120 | 18.40352 | 16.1905 | 20.6895 | 39.118 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.00000 |
2 | rowMins | 1.421211 | 1.346152 | 1.290208 | 1.263452 | 1.20519 | 1.58488 |
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 3155804 168.6 5709258 305.0 5709258 305.0
Vcells 5927700 45.3 22267496 169.9 56666022 432.4
> 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 3155795 168.6 5709258 305.0 5709258 305.0
Vcells 5937802 45.4 22267496 169.9 56666022 432.4
> 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.024620 | 0.0275000 | 0.0304335 | 0.0291165 | 0.0307555 | 0.067049 |
4 | lapply+pmin.int | 0.077571 | 0.0809720 | 0.0870117 | 0.0832275 | 0.0858395 | 0.269989 |
3 | lapply+pmin | 0.085062 | 0.0891845 | 0.0954976 | 0.0920500 | 0.0955835 | 0.201564 |
2 | apply+min | 0.795285 | 0.8154235 | 0.8691160 | 0.8392840 | 0.8656865 | 1.650140 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 3.150731 | 2.944436 | 2.859074 | 2.858431 | 2.791029 | 4.026742 |
3 | lapply+pmin | 3.454996 | 3.243073 | 3.137905 | 3.161438 | 3.107851 | 3.006219 |
2 | apply+min | 32.302396 | 29.651764 | 28.557834 | 28.825031 | 28.147372 | 24.610956 |
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.030372 | 0.0321985 | 0.0350688 | 0.033166 | 0.0349110 | 0.070459 |
4 | lapply+pmin.int | 0.060829 | 0.0628215 | 0.0684341 | 0.064228 | 0.0678125 | 0.164972 |
3 | lapply+pmin | 0.068250 | 0.0711025 | 0.0761724 | 0.073323 | 0.0773395 | 0.106776 |
2 | apply+min | 0.782291 | 0.8289390 | 0.8781201 | 0.853268 | 0.8887410 | 1.348696 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 2.002799 | 1.951069 | 1.951421 | 1.936562 | 1.942439 | 2.341390 |
3 | lapply+pmin | 2.247136 | 2.208255 | 2.172082 | 2.210788 | 2.215333 | 1.515435 |
2 | apply+min | 25.756980 | 25.744647 | 25.039888 | 25.727190 | 25.457334 | 19.141572 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 24.620 | 27.5000 | 30.43354 | 29.1165 | 30.7555 | 67.049 |
2 | rowMins | 30.372 | 32.1985 | 35.06885 | 33.1660 | 34.9110 | 70.459 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowMins | 1.233631 | 1.170854 | 1.152309 | 1.139079 | 1.135114 | 1.050858 |
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 3156024 168.6 5709258 305.0 5709258 305.0
Vcells 5929049 45.3 22267496 169.9 56666022 432.4
> 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 3156018 168.6 5709258 305.0 5709258 305.0
Vcells 6029156 46.0 22267496 169.9 56666022 432.4
> 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.125447 | 0.1293965 | 0.1383702 | 0.1340865 | 0.1430755 | 0.179716 |
4 | lapply+pmin.int | 0.844252 | 0.8605065 | 1.0237278 | 0.8729505 | 0.9542095 | 11.687480 |
3 | lapply+pmin | 0.894233 | 0.9153215 | 0.9705503 | 0.9329275 | 0.9927140 | 1.325962 |
2 | apply+min | 1.717592 | 1.7599595 | 2.0954581 | 1.8037595 | 1.9702600 | 12.374341 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 6.729950 | 6.650153 | 7.398468 | 6.510353 | 6.669272 | 65.033052 |
3 | lapply+pmin | 7.128373 | 7.073773 | 7.014155 | 6.957654 | 6.938393 | 7.378097 |
2 | apply+min | 13.691774 | 13.601291 | 15.143849 | 13.452208 | 13.770771 | 68.854977 |
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.145162 | 0.1474045 | 0.1567973 | 0.149268 | 0.1639280 | 0.207378 |
4 | lapply+pmin.int | 0.452342 | 0.4573810 | 0.5973159 | 0.473369 | 0.5424650 | 10.333709 |
3 | lapply+pmin | 0.498693 | 0.5114845 | 0.5593986 | 0.536469 | 0.6130055 | 0.695302 |
2 | apply+min | 1.286449 | 1.3035705 | 1.6513155 | 1.352268 | 1.5885595 | 11.654073 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | lapply+pmin.int | 3.116118 | 3.102897 | 3.809478 | 3.171269 | 3.309166 | 49.830305 |
3 | lapply+pmin | 3.435424 | 3.469938 | 3.567654 | 3.593999 | 3.739480 | 3.352824 |
2 | apply+min | 8.862161 | 8.843492 | 10.531528 | 9.059330 | 9.690593 | 56.197249 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 125.447 | 129.3965 | 138.3702 | 134.0865 | 143.0755 | 179.716 |
2 | rowMins | 145.162 | 147.4045 | 156.7973 | 149.2680 | 163.9280 | 207.378 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowMins | 1.157158 | 1.139169 | 1.133172 | 1.113222 | 1.145745 | 1.153921 |
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 3156260 168.6 5709258 305.0 5709258 305.0
Vcells 5929212 45.3 22267496 169.9 56666022 432.4
> 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 3156251 168.6 5709258 305.0 5709258 305.0
Vcells 6029314 46.1 22267496 169.9 56666022 432.4
> 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.087550 | 0.0908305 | 0.1005055 | 0.0979455 | 0.106838 | 0.148626 |
2 | apply+min | 0.618106 | 0.6392605 | 0.8212992 | 0.6531100 | 0.719426 | 13.715711 |
4 | lapply+pmin.int | 1.402662 | 1.4410135 | 1.7166064 | 1.4871865 | 1.705920 | 15.539851 |
3 | lapply+pmin | 1.838623 | 1.8596280 | 2.1403272 | 1.9354630 | 2.042736 | 14.988205 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | apply+min | 7.060034 | 7.03795 | 8.171682 | 6.668096 | 6.733803 | 92.28339 |
4 | lapply+pmin.int | 16.021268 | 15.86486 | 17.079723 | 15.183817 | 15.967352 | 104.55675 |
3 | lapply+pmin | 21.000834 | 20.47361 | 21.295619 | 19.760612 | 19.119934 | 100.84511 |
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.119345 | 0.1228785 | 0.1327945 | 0.1270245 | 0.1391235 | 0.178257 |
2 | apply+min | 0.644483 | 0.6641285 | 0.8757188 | 0.6867545 | 0.7476560 | 14.402261 |
4 | lapply+pmin.int | 1.194387 | 1.2165765 | 1.4497701 | 1.2433510 | 1.3700915 | 14.977114 |
3 | lapply+pmin | 1.628410 | 1.6549210 | 1.9395221 | 1.7027975 | 2.0019985 | 14.006635 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMins | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | apply+min | 5.400168 | 5.404757 | 6.594539 | 5.406473 | 5.374045 | 80.79493 |
4 | lapply+pmin.int | 10.007851 | 9.900646 | 10.917393 | 9.788277 | 9.848024 | 84.01978 |
3 | lapply+pmin | 13.644560 | 13.467946 | 14.605436 | 13.405268 | 14.390082 | 78.57551 |
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 | |
---|---|---|---|---|---|---|---|
1 | colMins | 87.550 | 90.8305 | 100.5055 | 97.9455 | 106.8380 | 148.626 |
2 | rowMins | 119.345 | 122.8785 | 132.7945 | 127.0245 | 139.1235 | 178.257 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMins | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 |
2 | rowMins | 1.363164 | 1.352833 | 1.321266 | 1.29689 | 1.302191 | 1.199366 |
Figure: Benchmarking of colMins() and rowMins() on double+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 30.52 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colMins')
Copyright Henrik Bengtsson. Last updated on 2019-09-10 20:46:16 (-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>