-
Notifications
You must be signed in to change notification settings - Fork 34
colRowProds
matrixStats: Benchmark report
This report benchmark the performance of colProds() and rowProds() against alternative methods.
- colProds()/rowProds() using method="expSumLog"
- apply() + prod()
- apply() + product()
> 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 = "double")
> X <- data[["10x10"]]
> colStats <- microbenchmark(`colProds w/ direct` = colProds(X, method = "direct", na.rm = FALSE),
+ `colProds w/ expSumLog` = colProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 2L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 2L, FUN = product,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> rowStats <- microbenchmark(`rowProds w/ direct` = rowProds(X, method = "direct", na.rm = FALSE),
+ `rowProds w/ expSumLog` = rowProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 1L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 1L, FUN = product,
+ na.rm = FALSE), unit = "ms")
Table: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 0.008800 | 0.0094145 | 0.0099799 | 0.0098050 | 0.0102595 | 0.021529 |
2 | colProds w/ expSumLog | 0.014226 | 0.0148440 | 0.0154650 | 0.0155405 | 0.0158780 | 0.019312 |
3 | apply+prod | 0.020025 | 0.0210960 | 0.0215453 | 0.0214540 | 0.0218900 | 0.028227 |
4 | apply+product | 0.027252 | 0.0277515 | 0.0293899 | 0.0280850 | 0.0284865 | 0.123770 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | colProds w/ expSumLog | 1.616591 | 1.576717 | 1.549612 | 1.584957 | 1.547639 | 0.8970226 |
3 | apply+prod | 2.275568 | 2.240799 | 2.158871 | 2.188067 | 2.133632 | 1.3111152 |
4 | apply+product | 3.096818 | 2.947740 | 2.944905 | 2.864355 | 2.776597 | 5.7489897 |
Table: Benchmarking of rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on 10x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 0.008971 | 0.0094915 | 0.0101705 | 0.0100415 | 0.0104500 | 0.020142 |
2 | rowProds w/ expSumLog | 0.014368 | 0.0149075 | 0.0159106 | 0.0156585 | 0.0162505 | 0.041111 |
3 | apply+prod | 0.019603 | 0.0206265 | 0.0223654 | 0.0212315 | 0.0216405 | 0.103849 |
4 | apply+product | 0.026428 | 0.0273865 | 0.0279480 | 0.0276900 | 0.0281740 | 0.037545 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowProds w/ expSumLog | 1.601605 | 1.570616 | 1.564385 | 1.559379 | 1.555072 | 2.041059 |
3 | apply+prod | 2.185152 | 2.173155 | 2.199039 | 2.114375 | 2.070861 | 5.155843 |
4 | apply+product | 2.945937 | 2.885371 | 2.747940 | 2.757556 | 2.696077 | 1.864016 |
Figure: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 10x10 data as well as rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 8.800 | 9.4145 | 9.97990 | 9.8050 | 10.2595 | 21.529 |
2 | rowProds w/ direct | 8.971 | 9.4915 | 10.17054 | 10.0415 | 10.4500 | 20.142 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.0000000 |
2 | rowProds w/ direct | 1.019432 | 1.008179 | 1.019102 | 1.02412 | 1.018568 | 0.9355753 |
Figure: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x100"]]
> colStats <- microbenchmark(`colProds w/ direct` = colProds(X, method = "direct", na.rm = FALSE),
+ `colProds w/ expSumLog` = colProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 2L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 2L, FUN = product,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> rowStats <- microbenchmark(`rowProds w/ direct` = rowProds(X, method = "direct", na.rm = FALSE),
+ `rowProds w/ expSumLog` = rowProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 1L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 1L, FUN = product,
+ na.rm = FALSE), unit = "ms")
Table: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 0.114208 | 0.1154645 | 0.1184836 | 0.1166710 | 0.1191515 | 0.168758 |
3 | apply+prod | 0.185868 | 0.1880695 | 0.1918381 | 0.1896675 | 0.1931980 | 0.212631 |
2 | colProds w/ expSumLog | 0.362362 | 0.3652075 | 0.3701785 | 0.3678675 | 0.3719820 | 0.397963 |
4 | apply+product | 0.444140 | 0.4475500 | 0.4544683 | 0.4501985 | 0.4545590 | 0.594481 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+prod | 1.627452 | 1.628808 | 1.619111 | 1.625661 | 1.621448 | 1.259976 |
2 | colProds w/ expSumLog | 3.172825 | 3.162942 | 3.124301 | 3.153033 | 3.121925 | 2.358188 |
4 | apply+product | 3.888869 | 3.876083 | 3.835705 | 3.858701 | 3.814967 | 3.522683 |
Table: Benchmarking of rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on 100x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 0.115724 | 0.1179720 | 0.1204872 | 0.1190215 | 0.1209745 | 0.167360 |
3 | apply+prod | 0.144730 | 0.1471305 | 0.1543799 | 0.1487155 | 0.1518415 | 0.540496 |
2 | rowProds w/ expSumLog | 0.366354 | 0.3695335 | 0.3764591 | 0.3714560 | 0.3754380 | 0.508744 |
4 | apply+product | 0.402775 | 0.4066835 | 0.4141205 | 0.4104350 | 0.4154095 | 0.519079 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+prod | 1.250648 | 1.247165 | 1.281297 | 1.249484 | 1.255153 | 3.229541 |
2 | rowProds w/ expSumLog | 3.165757 | 3.132383 | 3.124474 | 3.120915 | 3.103447 | 3.039818 |
4 | apply+product | 3.480479 | 3.447288 | 3.437050 | 3.448411 | 3.433860 | 3.101571 |
Figure: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 100x100 data as well as rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 100x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 114.208 | 115.4645 | 118.4836 | 116.6710 | 119.1515 | 168.758 |
2 | rowProds w/ direct | 115.724 | 117.9720 | 120.4872 | 119.0215 | 120.9745 | 167.360 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.0000 | 1.0000000 |
2 | rowProds w/ direct | 1.013274 | 1.021717 | 1.01691 | 1.020146 | 1.0153 | 0.9917159 |
Figure: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x10"]]
> colStats <- microbenchmark(`colProds w/ direct` = colProds(X, method = "direct", na.rm = FALSE),
+ `colProds w/ expSumLog` = colProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 2L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 2L, FUN = product,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> rowStats <- microbenchmark(`rowProds w/ direct` = rowProds(X, method = "direct", na.rm = FALSE),
+ `rowProds w/ expSumLog` = rowProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 1L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 1L, FUN = product,
+ na.rm = FALSE), unit = "ms")
Table: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 0.056584 | 0.0594655 | 0.0608798 | 0.0605925 | 0.0617985 | 0.076076 |
3 | apply+prod | 0.118388 | 0.1214215 | 0.1260853 | 0.1234645 | 0.1250075 | 0.223058 |
2 | colProds w/ expSumLog | 0.264604 | 0.2671600 | 0.2710972 | 0.2685945 | 0.2701615 | 0.351917 |
4 | apply+product | 0.328278 | 0.3319470 | 0.3385626 | 0.3333385 | 0.3350340 | 0.719578 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+prod | 2.092252 | 2.041881 | 2.071054 | 2.037620 | 2.022824 | 2.932042 |
2 | colProds w/ expSumLog | 4.676304 | 4.492689 | 4.452994 | 4.432801 | 4.371651 | 4.625861 |
4 | apply+product | 5.801605 | 5.582178 | 5.561168 | 5.501316 | 5.421394 | 9.458673 |
Table: Benchmarking of rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on 1000x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 0.058456 | 0.0606645 | 0.0625605 | 0.0625085 | 0.0636825 | 0.072641 |
3 | apply+prod | 0.076469 | 0.0810880 | 0.0838753 | 0.0829305 | 0.0848060 | 0.106722 |
2 | rowProds w/ expSumLog | 0.267670 | 0.2705885 | 0.2730204 | 0.2723735 | 0.2736355 | 0.292592 |
4 | apply+product | 0.287905 | 0.2904395 | 0.2956810 | 0.2922185 | 0.2960595 | 0.390372 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+prod | 1.308146 | 1.336663 | 1.340706 | 1.326708 | 1.331700 | 1.469170 |
2 | rowProds w/ expSumLog | 4.579000 | 4.460409 | 4.364101 | 4.357383 | 4.296871 | 4.027918 |
4 | apply+product | 4.925157 | 4.787635 | 4.726320 | 4.674860 | 4.648993 | 5.373990 |
Figure: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 1000x10 data as well as rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 1000x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 56.584 | 59.4655 | 60.87977 | 60.5925 | 61.7985 | 76.076 |
2 | rowProds w/ direct | 58.456 | 60.6645 | 62.56052 | 62.5085 | 63.6825 | 72.641 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowProds w/ direct | 1.033084 | 1.020163 | 1.027608 | 1.031621 | 1.030486 | 0.9548478 |
Figure: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["10x1000"]]
> colStats <- microbenchmark(`colProds w/ direct` = colProds(X, method = "direct", na.rm = FALSE),
+ `colProds w/ expSumLog` = colProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 2L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 2L, FUN = product,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> rowStats <- microbenchmark(`rowProds w/ direct` = rowProds(X, method = "direct", na.rm = FALSE),
+ `rowProds w/ expSumLog` = rowProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 1L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 1L, FUN = product,
+ na.rm = FALSE), unit = "ms")
Table: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 0.644066 | 0.684814 | 0.7599742 | 0.6989315 | 0.7216265 | 5.798954 |
3 | apply+prod | 0.812111 | 0.834671 | 0.8740589 | 0.8537895 | 0.8796950 | 1.472521 |
2 | colProds w/ expSumLog | 1.226847 | 1.278935 | 1.3722292 | 1.3015150 | 1.3495120 | 6.507626 |
4 | apply+product | 1.464395 | 1.505959 | 1.5636033 | 1.5311550 | 1.5869835 | 2.282037 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
3 | apply+prod | 1.260913 | 1.218829 | 1.150116 | 1.221564 | 1.219045 | 0.2539287 |
2 | colProds w/ expSumLog | 1.904847 | 1.867565 | 1.805626 | 1.862150 | 1.870098 | 1.1222069 |
4 | apply+product | 2.273672 | 2.199078 | 2.057443 | 2.190708 | 2.199176 | 0.3935256 |
Table: Benchmarking of rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on 10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 0.665562 | 0.702727 | 0.7232769 | 0.715927 | 0.7426305 | 0.802537 |
3 | apply+prod | 0.798166 | 0.830586 | 0.8740196 | 0.858047 | 0.8960415 | 1.202002 |
2 | rowProds w/ expSumLog | 1.248327 | 1.308507 | 1.4198041 | 1.349049 | 1.3859660 | 6.681312 |
4 | apply+product | 1.466300 | 1.523035 | 1.6262461 | 1.564934 | 1.6061500 | 6.903179 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+prod | 1.199236 | 1.181947 | 1.208416 | 1.198512 | 1.206578 | 1.497753 |
2 | rowProds w/ expSumLog | 1.875598 | 1.862042 | 1.963016 | 1.884339 | 1.866293 | 8.325239 |
4 | apply+product | 2.203101 | 2.167321 | 2.248442 | 2.185886 | 2.162785 | 8.601696 |
Figure: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 10x1000 data as well as rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 644.066 | 684.814 | 759.9742 | 698.9315 | 721.6265 | 5798.954 |
2 | rowProds w/ direct | 665.562 | 702.727 | 723.2769 | 715.9270 | 742.6305 | 802.537 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowProds w/ direct | 1.033376 | 1.026158 | 0.9517124 | 1.024316 | 1.029106 | 0.1383934 |
Figure: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x1000"]]
> colStats <- microbenchmark(`colProds w/ direct` = colProds(X, method = "direct", na.rm = FALSE),
+ `colProds w/ expSumLog` = colProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 2L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 2L, FUN = product,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> rowStats <- microbenchmark(`rowProds w/ direct` = rowProds(X, method = "direct", na.rm = FALSE),
+ `rowProds w/ expSumLog` = rowProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 1L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 1L, FUN = product,
+ na.rm = FALSE), unit = "ms")
Table: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.109562 | 1.120069 | 1.179608 | 1.139917 | 1.175838 | 1.720146 |
3 | apply+prod | 1.734878 | 1.757721 | 2.148371 | 1.782883 | 1.842180 | 17.418038 |
2 | colProds w/ expSumLog | 3.583810 | 3.615213 | 4.044786 | 3.647726 | 3.716857 | 19.286408 |
4 | apply+product | 4.305582 | 4.347441 | 4.700679 | 4.420883 | 4.504060 | 21.477891 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
3 | apply+prod | 1.563570 | 1.569297 | 1.821258 | 1.564046 | 1.566695 | 10.12591 |
2 | colProds w/ expSumLog | 3.229932 | 3.227670 | 3.428923 | 3.199993 | 3.161028 | 11.21208 |
4 | apply+product | 3.880434 | 3.881404 | 3.984949 | 3.878250 | 3.830510 | 12.48609 |
Table: Benchmarking of rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on 100x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 1.150689 | 1.169666 | 1.258584 | 1.179300 | 1.222171 | 1.889199 |
3 | apply+prod | 1.319024 | 1.338129 | 1.866213 | 1.355963 | 1.388661 | 17.378289 |
2 | rowProds w/ expSumLog | 3.640529 | 3.670341 | 3.997877 | 3.680613 | 3.730546 | 20.434404 |
4 | apply+product | 3.881884 | 3.928486 | 4.268454 | 3.944160 | 4.031906 | 20.527597 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
3 | apply+prod | 1.146291 | 1.144027 | 1.482788 | 1.149803 | 1.136224 | 9.19876 |
2 | rowProds w/ expSumLog | 3.163782 | 3.137939 | 3.176489 | 3.121015 | 3.052392 | 10.81644 |
4 | apply+product | 3.373530 | 3.358639 | 3.391473 | 3.344492 | 3.298970 | 10.86577 |
Figure: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 100x1000 data as well as rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 100x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.109562 | 1.120069 | 1.179608 | 1.139917 | 1.175838 | 1.720146 |
2 | rowProds w/ direct | 1.150689 | 1.169666 | 1.258584 | 1.179300 | 1.222171 | 1.889199 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowProds w/ direct | 1.037066 | 1.04428 | 1.066951 | 1.034549 | 1.039405 | 1.098278 |
Figure: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x100"]]
> colStats <- microbenchmark(`colProds w/ direct` = colProds(X, method = "direct", na.rm = FALSE),
+ `colProds w/ expSumLog` = colProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 2L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 2L, FUN = product,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> rowStats <- microbenchmark(`rowProds w/ direct` = rowProds(X, method = "direct", na.rm = FALSE),
+ `rowProds w/ expSumLog` = rowProds(X, method = "expSumLog", na.rm = FALSE), `apply+prod` = apply(X,
+ MARGIN = 1L, FUN = prod, na.rm = FALSE), `apply+product` = apply(X, MARGIN = 1L, FUN = product,
+ na.rm = FALSE), unit = "ms")
Table: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 0.363557 | 0.3716730 | 0.3887810 | 0.3839445 | 0.3921995 | 0.477998 |
3 | apply+prod | 0.640136 | 0.6542385 | 0.9097683 | 0.6858240 | 0.7200375 | 7.951854 |
2 | colProds w/ expSumLog | 2.418585 | 2.4573250 | 2.5319060 | 2.4730465 | 2.4955020 | 3.160826 |
4 | apply+product | 2.732607 | 2.7511875 | 2.9202926 | 2.7832505 | 2.8313660 | 9.714860 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+prod | 1.760758 | 1.760253 | 2.340053 | 1.786258 | 1.835896 | 16.635747 |
2 | colProds w/ expSumLog | 6.652561 | 6.611524 | 6.512422 | 6.441156 | 6.362838 | 6.612634 |
4 | apply+product | 7.516310 | 7.402172 | 7.511408 | 7.249096 | 7.219198 | 20.324060 |
Table: Benchmarking of rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on 1000x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 0.594052 | 0.602855 | 0.7037156 | 0.609530 | 0.6415405 | 7.690274 |
3 | apply+prod | 0.666871 | 0.684659 | 0.7341861 | 0.715175 | 0.7453200 | 1.080402 |
2 | rowProds w/ expSumLog | 2.701753 | 2.731766 | 2.9677295 | 2.741329 | 2.7817565 | 10.744616 |
4 | apply+product | 2.767487 | 2.815783 | 3.0263775 | 2.830687 | 2.8881060 | 15.105563 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowProds w/ direct | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
3 | apply+prod | 1.122580 | 1.135694 | 1.043300 | 1.173322 | 1.161766 | 0.1404894 |
2 | rowProds w/ expSumLog | 4.548008 | 4.531382 | 4.217229 | 4.497448 | 4.336057 | 1.3971695 |
4 | apply+product | 4.658661 | 4.670746 | 4.300569 | 4.644050 | 4.501830 | 1.9642425 |
Figure: Benchmarking of colProds w/ direct(), colProds w/ expSumLog(), apply+prod() and apply+product() on 1000x100 data as well as rowProds w/ direct(), rowProds w/ expSumLog(), apply+prod() and apply+product() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 1000x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 363.557 | 371.673 | 388.7810 | 383.9445 | 392.1995 | 477.998 |
2 | rowProds w/ direct | 594.052 | 602.855 | 703.7156 | 609.5300 | 641.5405 | 7690.274 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colProds w/ direct | 1.000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.00000 |
2 | rowProds w/ direct | 1.634 | 1.622004 | 1.810057 | 1.587547 | 1.63575 | 16.08851 |
Figure: Benchmarking of colProds w/ direct() and rowProds w/ direct() on 1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
R version 3.6.1 Patched (2019-08-27 r77078)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] microbenchmark_1.4-6 matrixStats_0.55.0-9000 ggplot2_3.2.1
[4] knitr_1.24 R.devices_2.16.0 R.utils_2.9.0
[7] R.oo_1.22.0 R.methodsS3_1.7.1 history_0.0.0-9002
loaded via a namespace (and not attached):
[1] Biobase_2.45.0 bit64_0.9-7 splines_3.6.1
[4] network_1.15 assertthat_0.2.1 highr_0.8
[7] stats4_3.6.1 blob_1.2.0 robustbase_0.93-5
[10] pillar_1.4.2 RSQLite_2.1.2 backports_1.1.4
[13] lattice_0.20-38 glue_1.3.1 digest_0.6.20
[16] colorspace_1.4-1 sandwich_2.5-1 Matrix_1.2-17
[19] XML_3.98-1.20 lpSolve_5.6.13.3 pkgconfig_2.0.2
[22] genefilter_1.66.0 purrr_0.3.2 ergm_3.10.4
[25] xtable_1.8-4 mvtnorm_1.0-11 scales_1.0.0
[28] tibble_2.1.3 annotate_1.62.0 IRanges_2.18.2
[31] TH.data_1.0-10 withr_2.1.2 BiocGenerics_0.30.0
[34] lazyeval_0.2.2 mime_0.7 survival_2.44-1.1
[37] magrittr_1.5 crayon_1.3.4 statnet.common_4.3.0
[40] memoise_1.1.0 laeken_0.5.0 R.cache_0.13.0
[43] MASS_7.3-51.4 R.rsp_0.43.1 tools_3.6.1
[46] multcomp_1.4-10 S4Vectors_0.22.1 trust_0.1-7
[49] munsell_0.5.0 AnnotationDbi_1.46.1 compiler_3.6.1
[52] rlang_0.4.0 grid_3.6.1 RCurl_1.95-4.12
[55] cwhmisc_6.6 rappdirs_0.3.1 labeling_0.3
[58] bitops_1.0-6 base64enc_0.1-3 boot_1.3-23
[61] gtable_0.3.0 codetools_0.2-16 DBI_1.0.0
[64] markdown_1.1 R6_2.4.0 zoo_1.8-6
[67] dplyr_0.8.3 bit_1.1-14 zeallot_0.1.0
[70] parallel_3.6.1 Rcpp_1.0.2 vctrs_0.2.0
[73] DEoptimR_1.0-8 tidyselect_0.2.5 xfun_0.9
[76] coda_0.19-3
Total processing time was 17.46 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colProds')
Copyright Henrik Bengtsson. Last updated on 2019-09-10 20:49:13 (-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>