-
Notifications
You must be signed in to change notification settings - Fork 0
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), 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 = "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 |
|---|---|---|---|---|---|---|
| colProds w/ direct | 0.0166 | 0.0204 | 0.0244 | 0.0231 | 0.0254 | 0.0370 |
| colProds w/ expSumLog | 0.0389 | 0.0427 | 0.0494 | 0.0450 | 0.0466 | 0.2210 |
| apply+prod | 0.0562 | 0.0601 | 0.0707 | 0.0633 | 0.0695 | 0.2556 |
| apply+product | 0.0801 | 0.0837 | 0.0927 | 0.0858 | 0.0889 | 0.2718 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| colProds w/ expSumLog | 2.349 | 2.094 | 2.019 | 1.950 | 1.833 | 5.979 |
| apply+prod | 3.395 | 2.943 | 2.893 | 2.742 | 2.735 | 6.916 |
| apply+product | 4.837 | 4.104 | 3.793 | 3.716 | 3.500 | 7.354 |
| 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 |
|---|---|---|---|---|---|---|
| rowProds w/ direct | 0.0169 | 0.0198 | 0.0287 | 0.0227 | 0.0346 | 0.2610 |
| rowProds w/ expSumLog | 0.0377 | 0.0416 | 0.0533 | 0.0450 | 0.0683 | 0.0989 |
| apply+prod | 0.0566 | 0.0597 | 0.0753 | 0.0641 | 0.0945 | 0.1151 |
| apply+product | 0.0801 | 0.0832 | 0.1058 | 0.0860 | 0.1320 | 0.1786 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| rowProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.0000 |
| rowProds w/ expSumLog | 2.227 | 2.097 | 1.859 | 1.983 | 1.972 | 0.3791 |
| apply+prod | 3.341 | 3.010 | 2.626 | 2.822 | 2.728 | 0.4410 |
| apply+product | 4.727 | 4.194 | 3.686 | 3.788 | 3.811 | 0.6844 |
| 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 | |
|---|---|---|---|---|---|---|---|
| 2 | rowProds w/ direct | 16.94 | 19.83 | 28.70 | 22.71 | 34.65 | 261.00 |
| 1 | colProds w/ direct | 16.55 | 20.40 | 24.45 | 23.10 | 25.41 | 36.96 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowProds w/ direct | 1.0000 | 1.000 | 1.000 | 1.000 | 1.0000 | 1.0000 |
| 1 | colProds w/ direct | 0.9773 | 1.029 | 0.852 | 1.017 | 0.7333 | 0.1416 |
| 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.2364 | 0.2637 | 0.3825 | 0.4229 | 0.4410 | 0.7279 |
| 3 | apply+prod | 0.3934 | 0.4804 | 0.6621 | 0.7106 | 0.7807 | 1.0209 |
| 2 | colProds w/ expSumLog | 0.7572 | 0.7996 | 1.2270 | 1.1726 | 1.1993 | 14.5982 |
| 4 | apply+product | 0.9220 | 1.0007 | 1.5001 | 1.4923 | 1.5733 | 15.7754 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 1.665 | 1.822 | 1.731 | 1.681 | 1.770 | 1.402 |
| 2 | colProds w/ expSumLog | 3.204 | 3.032 | 3.208 | 2.773 | 2.720 | 20.054 |
| 4 | apply+product | 3.901 | 3.795 | 3.921 | 3.529 | 3.568 | 21.671 |
| 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.2063 | 0.2523 | 0.5141 | 0.3765 | 0.4011 | 16.856 |
| 3 | apply+prod | 0.3969 | 0.5245 | 0.7312 | 0.7099 | 0.8032 | 3.802 |
| 2 | rowProds w/ expSumLog | 0.7241 | 0.7849 | 1.0789 | 1.1293 | 1.1889 | 4.586 |
| 4 | apply+product | 0.9689 | 1.4289 | 1.4834 | 1.5429 | 1.6097 | 2.071 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.0000 |
| 3 | apply+prod | 1.923 | 2.079 | 1.422 | 1.885 | 2.002 | 0.2255 |
| 2 | rowProds w/ expSumLog | 3.509 | 3.111 | 2.099 | 2.999 | 2.964 | 0.2721 |
| 4 | apply+product | 4.696 | 5.663 | 2.885 | 4.098 | 4.013 | 0.1229 |
| 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 | |
|---|---|---|---|---|---|---|---|
| 2 | rowProds w/ direct | 206.3 | 252.3 | 514.1 | 376.5 | 401.1 | 16856.4 |
| 1 | colProds w/ direct | 236.4 | 263.7 | 382.5 | 422.9 | 441.0 | 727.9 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowProds w/ direct | 1.000 | 1.000 | 1.0000 | 1.000 | 1.000 | 1.0000 |
| 1 | colProds w/ direct | 1.145 | 1.045 | 0.7441 | 1.123 | 1.099 | 0.0432 |
| 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.1313 | 0.1394 | 0.1681 | 0.1461 | 0.2027 | 0.2810 |
| 3 | apply+prod | 0.2348 | 0.2641 | 0.3306 | 0.3299 | 0.3669 | 0.5909 |
| 2 | colProds w/ expSumLog | 0.4850 | 0.4922 | 0.5446 | 0.4987 | 0.5214 | 0.7283 |
| 4 | apply+product | 0.5978 | 0.6238 | 0.7360 | 0.6921 | 0.8694 | 1.0401 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 1.789 | 1.895 | 1.967 | 2.258 | 1.810 | 2.103 |
| 2 | colProds w/ expSumLog | 3.695 | 3.532 | 3.240 | 3.414 | 2.573 | 2.592 |
| 4 | apply+product | 4.554 | 4.476 | 4.379 | 4.738 | 4.290 | 3.701 |
| 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.0993 | 0.1166 | 0.1457 | 0.1494 | 0.1653 | 0.2179 |
| 3 | apply+prod | 0.2402 | 0.3505 | 0.4167 | 0.4258 | 0.4718 | 0.8731 |
| 2 | rowProds w/ expSumLog | 0.4585 | 0.5151 | 0.6145 | 0.6533 | 0.6679 | 0.7922 |
| 4 | apply+product | 0.6063 | 0.7116 | 0.8683 | 0.8966 | 0.9751 | 1.9355 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 2.419 | 3.005 | 2.860 | 2.850 | 2.853 | 4.007 |
| 2 | rowProds w/ expSumLog | 4.616 | 4.416 | 4.217 | 4.374 | 4.040 | 3.636 |
| 4 | apply+product | 6.105 | 6.101 | 5.959 | 6.003 | 5.897 | 8.883 |
| 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 |
|---|---|---|---|---|---|---|
| colProds w/ direct | 131.27 | 139.4 | 168.1 | 146.1 | 202.7 | 281.0 |
| rowProds w/ direct | 99.32 | 116.6 | 145.7 | 149.4 | 165.3 | 217.9 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colProds w/ direct | 1.0000 | 1.000 | 1.0000 | 1.000 | 1.0000 | 1.0000 |
| rowProds w/ direct | 0.7566 | 0.837 | 0.8668 | 1.022 | 0.8158 | 0.7753 |
| 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 | 1.327 | 1.469 | 1.979 | 1.597 | 2.567 | 4.458 |
| 3 | apply+prod | 2.087 | 2.249 | 3.134 | 2.483 | 3.924 | 8.394 |
| 2 | colProds w/ expSumLog | 3.400 | 3.604 | 4.783 | 3.771 | 5.864 | 9.653 |
| 4 | apply+product | 4.279 | 4.542 | 5.954 | 5.162 | 7.250 | 10.602 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 1.572 | 1.531 | 1.584 | 1.555 | 1.529 | 1.883 |
| 2 | colProds w/ expSumLog | 2.562 | 2.454 | 2.417 | 2.361 | 2.285 | 2.165 |
| 4 | apply+product | 3.224 | 3.092 | 3.008 | 3.232 | 2.825 | 2.378 |
| 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 | 1.436 | 1.615 | 2.118 | 1.786 | 2.519 | 6.415 |
| 3 | apply+prod | 2.043 | 2.193 | 3.003 | 2.355 | 3.838 | 7.292 |
| 2 | rowProds w/ expSumLog | 3.406 | 3.694 | 4.772 | 4.027 | 5.802 | 12.706 |
| 4 | apply+product | 4.249 | 4.535 | 5.636 | 4.844 | 6.857 | 9.381 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 1.423 | 1.358 | 1.418 | 1.318 | 1.523 | 1.137 |
| 2 | rowProds w/ expSumLog | 2.372 | 2.287 | 2.253 | 2.254 | 2.303 | 1.981 |
| 4 | apply+product | 2.959 | 2.807 | 2.662 | 2.712 | 2.721 | 1.462 |
| 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 |
|---|---|---|---|---|---|---|
| colProds w/ direct | 1.327 | 1.469 | 1.979 | 1.597 | 2.567 | 4.458 |
| rowProds w/ direct | 1.436 | 1.615 | 2.118 | 1.786 | 2.519 | 6.415 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colProds w/ direct | 1.000 | 1.0 | 1.00 | 1.000 | 1.0000 | 1.000 |
| rowProds w/ direct | 1.082 | 1.1 | 1.07 | 1.119 | 0.9816 | 1.439 |
| 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 | 2.361 | 2.531 | 3.967 | 3.021 | 4.323 | 20.27 |
| 3 | apply+prod | 3.700 | 4.506 | 5.894 | 5.275 | 6.656 | 22.81 |
| 2 | colProds w/ expSumLog | 7.782 | 8.275 | 10.933 | 10.757 | 11.903 | 26.87 |
| 4 | apply+product | 9.237 | 10.313 | 12.816 | 12.427 | 14.210 | 31.85 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 1.567 | 1.781 | 1.486 | 1.746 | 1.540 | 1.125 |
| 2 | colProds w/ expSumLog | 3.296 | 3.270 | 2.756 | 3.561 | 2.753 | 1.326 |
| 4 | apply+product | 3.912 | 4.075 | 3.230 | 4.114 | 3.287 | 1.571 |
| 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 | 2.406 | 2.681 | 3.413 | 2.756 | 3.433 | 20.57 |
| 3 | apply+prod | 4.195 | 6.266 | 6.863 | 6.438 | 8.002 | 16.99 |
| 2 | rowProds w/ expSumLog | 7.617 | 8.025 | 9.986 | 8.255 | 11.275 | 27.86 |
| 4 | apply+product | 9.549 | 11.675 | 13.543 | 12.001 | 16.285 | 23.64 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 1.744 | 2.337 | 2.011 | 2.336 | 2.331 | 0.826 |
| 2 | rowProds w/ expSumLog | 3.166 | 2.993 | 2.926 | 2.995 | 3.285 | 1.355 |
| 4 | apply+product | 3.969 | 4.354 | 3.968 | 4.354 | 4.744 | 1.149 |
| 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 | |
|---|---|---|---|---|---|---|---|
| 2 | rowProds w/ direct | 2.406 | 2.681 | 3.413 | 2.756 | 3.433 | 20.57 |
| 1 | colProds w/ direct | 2.361 | 2.531 | 3.967 | 3.021 | 4.323 | 20.27 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowProds w/ direct | 1.0000 | 1.0000 | 1.000 | 1.000 | 1.000 | 1.0000 |
| 1 | colProds w/ direct | 0.9814 | 0.9438 | 1.163 | 1.096 | 1.259 | 0.9854 |
| 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 | 1.295 | 1.361 | 1.687 | 1.690 | 1.929 | 2.824 |
| 3 | apply+prod | 2.097 | 2.919 | 3.307 | 3.042 | 3.683 | 14.382 |
| 2 | colProds w/ expSumLog | 4.837 | 4.971 | 5.825 | 5.611 | 6.563 | 7.701 |
| 4 | apply+product | 5.690 | 6.593 | 7.682 | 7.218 | 8.625 | 19.188 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 1.620 | 2.144 | 1.960 | 1.800 | 1.910 | 5.093 |
| 2 | colProds w/ expSumLog | 3.736 | 3.652 | 3.453 | 3.320 | 3.403 | 2.728 |
| 4 | apply+product | 4.395 | 4.843 | 4.554 | 4.271 | 4.472 | 6.795 |
| 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 | 1.144 | 1.528 | 2.069 | 2.118 | 2.511 | 3.996 |
| 3 | apply+prod | 2.387 | 3.326 | 4.794 | 4.552 | 5.553 | 16.424 |
| 2 | rowProds w/ expSumLog | 5.096 | 5.206 | 6.415 | 6.510 | 7.382 | 12.879 |
| 4 | apply+product | 6.047 | 7.286 | 8.624 | 8.717 | 9.871 | 15.870 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowProds w/ direct | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | apply+prod | 2.086 | 2.177 | 2.317 | 2.149 | 2.212 | 4.110 |
| 2 | rowProds w/ expSumLog | 4.454 | 3.408 | 3.100 | 3.073 | 2.940 | 3.223 |
| 4 | apply+product | 5.286 | 4.770 | 4.168 | 4.115 | 3.931 | 3.972 |
| 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 |
|---|---|---|---|---|---|---|
| colProds w/ direct | 1.295 | 1.361 | 1.687 | 1.690 | 1.929 | 2.824 |
| rowProds w/ direct | 1.144 | 1.528 | 2.069 | 2.118 | 2.511 | 3.996 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colProds w/ direct | 1.0000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| rowProds w/ direct | 0.8837 | 1.122 | 1.227 | 1.253 | 1.302 | 1.415 |
| 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 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 BiocGenerics_0.13.6 splines_3.2.0
[4] MASS_7.3-39 munsell_0.4.2 lattice_0.20-30
[7] colorspace_1.2-4 R.cache_0.11.1-9000 multcomp_1.3-9
[10] stringr_0.6.2 plyr_1.8.1 tools_3.2.0
[13] parallel_3.2.0 grid_3.2.0 Biobase_2.27.2
[16] gtable_0.1.2 TH.data_1.0-6 survival_2.38-1
[19] digest_0.6.8 R.rsp_0.20.0 reshape2_1.4.1
[22] formatR_1.0.3 base64enc_0.1-3 mime_0.2.1
[25] evaluate_0.5.7 labeling_0.3 sandwich_2.3-2
[28] scales_0.2.4 mvtnorm_1.0-2 zoo_1.7-12
[31] Cairo_1.5-6 proto_0.3-10 Total processing time was 36.57 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colProds')Copyright Henrik Bengtsson. Last updated on 2015-03-02 17:15:41 (-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)