-
Notifications
You must be signed in to change notification settings - Fork 0
colRowLogSumExps
matrixStats: Benchmark report
This report benchmark the performance of colLogSumExps() and rowLogSumExps() against alternative methods.
- apply() + matrixStats::logSumExp()
- apply() + logSumExp0()
where
> logSumExp0 <- function(lx, ...) {
+ iMax <- which.max(lx)
+ log1p(sum(exp(lx[-iMax] - lx[iMax]))) + lx[iMax]
+ }> 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"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 654179 35.0 1168576 62.5 1168576 62.5
Vcells 12247870 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colLogSumExps = colLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 2L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 2L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652373 34.9 1168576 62.5 1168576 62.5
Vcells 12242543 93.5 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowLogSumExps = rowLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 1L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 1L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")Table: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 0.0115 | 0.0175 | 0.0231 | 0.0216 | 0.0262 | 0.1139 |
| apply+logSumExp | 0.0858 | 0.1066 | 0.1348 | 0.1409 | 0.1526 | 0.2922 |
| apply+logSumExp0 | 0.1143 | 0.1347 | 0.1832 | 0.1823 | 0.2102 | 0.5759 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 7.433 | 6.088 | 5.837 | 6.536 | 5.831 | 2.564 |
| apply+logSumExp0 | 9.900 | 7.692 | 7.934 | 8.455 | 8.029 | 5.054 |
| Table: Benchmarking of rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() 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 |
|---|---|---|---|---|---|---|
| rowLogSumExps | 0.0108 | 0.0119 | 0.0156 | 0.0146 | 0.0158 | 0.1455 |
| apply+logSumExp | 0.0828 | 0.0874 | 0.0891 | 0.0889 | 0.0905 | 0.0985 |
| apply+logSumExp0 | 0.1082 | 0.1163 | 0.1222 | 0.1191 | 0.1209 | 0.2749 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| rowLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.0000 |
| apply+logSumExp | 7.678 | 7.322 | 5.717 | 6.079 | 5.731 | 0.6772 |
| apply+logSumExp0 | 10.036 | 9.741 | 7.846 | 8.144 | 7.658 | 1.8889 |
| Figure: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 10x10 data as well as rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colLogSumExps() and rowLogSumExps() 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 | rowLogSumExps | 10.78 | 11.94 | 15.58 | 14.63 | 15.78 | 145.5 |
| 1 | colLogSumExps | 11.55 | 17.52 | 23.09 | 21.56 | 26.18 | 113.9 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.0000 |
| 1 | colLogSumExps | 1.071 | 1.468 | 1.482 | 1.474 | 1.659 | 0.7831 |
| Figure: Benchmarking of colLogSumExps() and rowLogSumExps() on 10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652504 34.9 1168576 62.5 1168576 62.5
Vcells 12243794 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colLogSumExps = colLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 2L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 2L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652498 34.9 1168576 62.5 1168576 62.5
Vcells 12253837 93.5 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowLogSumExps = rowLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 1L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 1L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")Table: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 0.4985 | 0.7018 | 0.7336 | 0.7291 | 0.7589 | 1.921 |
| apply+logSumExp | 1.1048 | 1.7958 | 1.9953 | 1.9003 | 1.9706 | 13.446 |
| apply+logSumExp0 | 1.5514 | 2.4949 | 2.6120 | 2.6127 | 2.6864 | 4.294 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.00 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 2.216 | 2.559 | 2.72 | 2.606 | 2.596 | 7.000 |
| apply+logSumExp0 | 3.112 | 3.555 | 3.56 | 3.583 | 3.540 | 2.235 |
| Table: Benchmarking of rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() 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 |
|---|---|---|---|---|---|---|
| rowLogSumExps | 0.5278 | 0.7882 | 0.8966 | 0.8354 | 0.8804 | 3.462 |
| apply+logSumExp | 1.1887 | 1.8312 | 2.2091 | 1.9340 | 2.1284 | 13.836 |
| apply+logSumExp0 | 1.6145 | 2.4868 | 2.6728 | 2.6475 | 2.7463 | 9.375 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| rowLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 2.252 | 2.323 | 2.464 | 2.315 | 2.418 | 3.997 |
| apply+logSumExp0 | 3.059 | 3.155 | 2.981 | 3.169 | 3.119 | 2.708 |
| Figure: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 100x100 data as well as rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colLogSumExps() and rowLogSumExps() 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 |
|---|---|---|---|---|---|---|
| colLogSumExps | 498.5 | 701.8 | 733.6 | 729.1 | 758.9 | 1921 |
| rowLogSumExps | 527.8 | 788.2 | 896.6 | 835.4 | 880.4 | 3462 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 | 1.000 |
| rowLogSumExps | 1.059 | 1.123 | 1.222 | 1.146 | 1.16 | 1.802 |
| Figure: Benchmarking of colLogSumExps() and rowLogSumExps() on 100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652544 34.9 1168576 62.5 1168576 62.5
Vcells 12244028 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colLogSumExps = colLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 2L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 2L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652538 34.9 1168576 62.5 1168576 62.5
Vcells 12254071 93.5 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowLogSumExps = rowLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 1L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 1L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")Table: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 0.4897 | 0.696 | 0.6985 | 0.7129 | 0.726 | 0.8088 |
| apply+logSumExp | 0.7403 | 1.167 | 1.2029 | 1.2134 | 1.252 | 2.3798 |
| apply+logSumExp0 | 0.9616 | 1.454 | 1.4749 | 1.4996 | 1.535 | 1.7550 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 1.512 | 1.677 | 1.722 | 1.702 | 1.725 | 2.942 |
| apply+logSumExp0 | 1.964 | 2.089 | 2.111 | 2.103 | 2.115 | 2.170 |
| Table: Benchmarking of rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() 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 |
|---|---|---|---|---|---|---|
| rowLogSumExps | 0.5193 | 0.5380 | 0.6781 | 0.733 | 0.7728 | 0.8196 |
| apply+logSumExp | 0.7291 | 0.8126 | 1.0324 | 1.130 | 1.2203 | 1.8924 |
| apply+logSumExp0 | 0.9366 | 1.0334 | 1.2983 | 1.442 | 1.5029 | 1.7704 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| rowLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 1.404 | 1.511 | 1.522 | 1.541 | 1.579 | 2.309 |
| apply+logSumExp0 | 1.804 | 1.921 | 1.915 | 1.967 | 1.945 | 2.160 |
| Figure: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 1000x10 data as well as rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colLogSumExps() and rowLogSumExps() 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 |
|---|---|---|---|---|---|---|
| colLogSumExps | 489.7 | 696 | 698.5 | 712.9 | 726.0 | 808.8 |
| rowLogSumExps | 519.3 | 538 | 678.1 | 733.0 | 772.8 | 819.6 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.00 | 1.000 | 1.0000 | 1.000 | 1.000 | 1.000 |
| rowLogSumExps | 1.06 | 0.773 | 0.9708 | 1.028 | 1.064 | 1.013 |
| Figure: Benchmarking of colLogSumExps() and rowLogSumExps() on 1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["10x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652574 34.9 1168576 62.5 1168576 62.5
Vcells 12244684 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colLogSumExps = colLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 2L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 2L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652568 34.9 1168576 62.5 1168576 62.5
Vcells 12254727 93.5 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowLogSumExps = rowLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 1L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 1L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")Table: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 0.5478 | 0.5782 | 0.6905 | 0.7152 | 0.7816 | 1.268 |
| apply+logSumExp | 4.5359 | 4.9241 | 7.3256 | 7.3143 | 8.1495 | 37.867 |
| apply+logSumExp0 | 7.5624 | 8.4844 | 11.3999 | 11.6254 | 13.1914 | 20.483 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.00 | 1.000 | 1.00 | 1.00 | 1.00 | 1.00 |
| apply+logSumExp | 8.28 | 8.516 | 10.61 | 10.23 | 10.43 | 29.85 |
| apply+logSumExp0 | 13.81 | 14.674 | 16.51 | 16.25 | 16.88 | 16.15 |
| Table: Benchmarking of rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() 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 |
|---|---|---|---|---|---|---|
| rowLogSumExps | 0.5682 | 0.6077 | 0.7344 | 0.7154 | 0.8517 | 1.487 |
| apply+logSumExp | 4.4404 | 4.8479 | 6.6653 | 6.3040 | 8.0638 | 16.329 |
| apply+logSumExp0 | 7.5632 | 8.2886 | 11.5799 | 12.2136 | 13.3396 | 19.998 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| rowLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 |
| apply+logSumExp | 7.815 | 7.978 | 9.076 | 8.811 | 9.468 | 10.98 |
| apply+logSumExp0 | 13.311 | 13.640 | 15.767 | 17.072 | 15.662 | 13.45 |
| Figure: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 10x1000 data as well as rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colLogSumExps() and rowLogSumExps() 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 |
|---|---|---|---|---|---|---|
| colLogSumExps | 547.8 | 578.2 | 690.5 | 715.2 | 781.6 | 1268 |
| rowLogSumExps | 568.2 | 607.7 | 734.4 | 715.4 | 851.7 | 1487 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.000 | 1 | 1.00 | 1.000 |
| rowLogSumExps | 1.037 | 1.051 | 1.064 | 1 | 1.09 | 1.172 |
| Figure: Benchmarking of colLogSumExps() and rowLogSumExps() on 10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652618 34.9 1168576 62.5 1168576 62.5
Vcells 12245096 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colLogSumExps = colLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 2L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 2L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652612 34.9 1168576 62.5 1168576 62.5
Vcells 12345139 94.2 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowLogSumExps = rowLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 1L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 1L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")Table: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 4.987 | 5.125 | 6.197 | 6.467 | 7.034 | 8.882 |
| apply+logSumExp | 10.689 | 12.077 | 16.137 | 16.907 | 17.795 | 35.634 |
| apply+logSumExp0 | 15.399 | 18.637 | 22.930 | 23.486 | 25.178 | 38.215 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 2.143 | 2.356 | 2.604 | 2.614 | 2.530 | 4.012 |
| apply+logSumExp0 | 3.088 | 3.636 | 3.700 | 3.631 | 3.579 | 4.303 |
| Table: Benchmarking of rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() 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 |
|---|---|---|---|---|---|---|
| rowLogSumExps | 5.711 | 5.756 | 6.783 | 5.974 | 7.872 | 12.23 |
| apply+logSumExp | 11.405 | 13.741 | 16.343 | 16.003 | 18.308 | 26.92 |
| apply+logSumExp0 | 16.547 | 18.789 | 22.424 | 21.983 | 25.082 | 38.72 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| rowLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 1.997 | 2.387 | 2.409 | 2.679 | 2.326 | 2.201 |
| apply+logSumExp0 | 2.897 | 3.264 | 3.306 | 3.680 | 3.186 | 3.166 |
| Figure: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 100x1000 data as well as rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colLogSumExps() and rowLogSumExps() 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 | rowLogSumExps | 5.711 | 5.756 | 6.783 | 5.974 | 7.872 | 12.229 |
| 1 | colLogSumExps | 4.987 | 5.125 | 6.197 | 6.467 | 7.034 | 8.882 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowLogSumExps | 1.0000 | 1.0000 | 1.0000 | 1.000 | 1.0000 | 1.0000 |
| 1 | colLogSumExps | 0.8733 | 0.8904 | 0.9136 | 1.083 | 0.8936 | 0.7263 |
| Figure: Benchmarking of colLogSumExps() and rowLogSumExps() on 100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652649 34.9 1168576 62.5 1168576 62.5
Vcells 12245594 93.5 35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colLogSumExps = colLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 2L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 2L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 652643 34.9 1168576 62.5 1168576 62.5
Vcells 12345637 94.2 35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowLogSumExps = rowLogSumExps(X, na.rm = FALSE), `apply+logSumExp` = apply(X,
+ MARGIN = 1L, FUN = logSumExp, na.rm = FALSE), `apply+logSumExp0` = apply(X, MARGIN = 1L, FUN = logSumExp0,
+ na.rm = FALSE), unit = "ms")Table: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 4.894 | 4.920 | 5.847 | 5.186 | 6.928 | 8.537 |
| apply+logSumExp | 7.117 | 7.917 | 9.369 | 8.845 | 11.085 | 15.001 |
| apply+logSumExp0 | 9.180 | 10.060 | 11.784 | 11.339 | 13.444 | 21.254 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.00 | 1.000 |
| apply+logSumExp | 1.454 | 1.609 | 1.602 | 1.706 | 1.60 | 1.757 |
| apply+logSumExp0 | 1.876 | 2.045 | 2.015 | 2.186 | 1.94 | 2.490 |
| Table: Benchmarking of rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() 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 |
|---|---|---|---|---|---|---|
| rowLogSumExps | 5.601 | 5.655 | 6.79 | 5.975 | 8.103 | 8.957 |
| apply+logSumExp | 7.598 | 9.131 | 10.13 | 9.409 | 11.600 | 16.795 |
| apply+logSumExp0 | 9.843 | 11.255 | 12.51 | 12.061 | 13.926 | 18.681 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| rowLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| apply+logSumExp | 1.357 | 1.615 | 1.491 | 1.575 | 1.431 | 1.875 |
| apply+logSumExp0 | 1.757 | 1.990 | 1.843 | 2.019 | 1.719 | 2.086 |
| Figure: Benchmarking of colLogSumExps(), apply+logSumExp() and apply+logSumExp0() on 1000x100 data as well as rowLogSumExps(), apply+logSumExp() and apply+logSumExp0() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colLogSumExps() and rowLogSumExps() 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 |
|---|---|---|---|---|---|---|
| colLogSumExps | 4.894 | 4.920 | 5.847 | 5.186 | 6.928 | 8.537 |
| rowLogSumExps | 5.601 | 5.655 | 6.790 | 5.975 | 8.103 | 8.957 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| colLogSumExps | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| rowLogSumExps | 1.145 | 1.149 | 1.161 | 1.152 | 1.169 | 1.049 |
| Figure: Benchmarking of colLogSumExps() and rowLogSumExps() 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 splines_3.2.0 MASS_7.3-39
[4] munsell_0.4.2 lattice_0.20-30 colorspace_1.2-4
[7] R.cache_0.11.1-9000 multcomp_1.3-9 stringr_0.6.2
[10] plyr_1.8.1 tools_3.2.0 grid_3.2.0
[13] gtable_0.1.2 TH.data_1.0-6 survival_2.38-1
[16] digest_0.6.8 R.rsp_0.20.0 reshape2_1.4.1
[19] formatR_1.0.3 base64enc_0.1-3 mime_0.2.1
[22] evaluate_0.5.7 labeling_0.3 sandwich_2.3-2
[25] scales_0.2.4 mvtnorm_1.0-2 zoo_1.7-12
[28] Cairo_1.5-6 proto_0.3-10 Total processing time was 36.84 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colLogSumExps')Copyright Henrik Bengtsson. Last updated on 2015-03-02 17:03:36 (-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)