colRowLogSumExps_subset - HenrikBengtsson/matrixStats GitHub Wiki

matrixStats: Benchmark report


colLogSumExps() and rowLogSumExps() benchmarks on subsetted computation

This report benchmark the performance of colLogSumExps() and rowLogSumExps() on subsetted computation.

Data

> 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")

Results

10x10 matrix

> X <- data[["10x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3121541 166.8    5709258 305.0  5709258 305.0
Vcells 6004425  45.9   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colLogSumExps_X_S = colLogSumExps(X_S, na.rm = FALSE), `colLogSumExps(X, rows, cols)` = colLogSumExps(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colLogSumExps(X[rows, cols])` = colLogSumExps(X[rows, 
+     cols], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3120977 166.7    5709258 305.0  5709258 305.0
Vcells 6003220  45.9   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowLogSumExps_X_S = rowLogSumExps(X_S, na.rm = FALSE), `rowLogSumExps(X, cols, rows)` = rowLogSumExps(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowLogSumExps(X[cols, rows])` = rowLogSumExps(X[cols, 
+     rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() 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 colLogSumExps_X_S 0.003764 0.0040045 0.0055583 0.0040865 0.0042460 0.145171
2 colLogSumExps(X, rows, cols) 0.004068 0.0043825 0.0046240 0.0045340 0.0047475 0.007722
3 colLogSumExps(X[rows, cols]) 0.004394 0.0049760 0.0052400 0.0051195 0.0053150 0.011950
expr min lq mean median uq max
1 colLogSumExps_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colLogSumExps(X, rows, cols) 1.080765 1.094394 0.8319132 1.109507 1.118111 0.0531924
3 colLogSumExps(X[rows, cols]) 1.167375 1.242602 0.9427219 1.252784 1.251766 0.0823167

Table: Benchmarking of rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() 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 rowLogSumExps_X_S 0.003118 0.0034090 0.0036168 0.003520 0.0036640 0.008098
2 rowLogSumExps(X, cols, rows) 0.003460 0.0037595 0.0052684 0.003878 0.0040725 0.135635
3 rowLogSumExps(X[cols, rows]) 0.003852 0.0042680 0.0044754 0.004404 0.0045265 0.008932
expr min lq mean median uq max
1 rowLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowLogSumExps(X, cols, rows) 1.109686 1.102816 1.456663 1.101705 1.111490 16.749197
3 rowLogSumExps(X[cols, rows]) 1.235407 1.251980 1.237417 1.251136 1.235399 1.102988

Figure: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() on 10x10 data as well as rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() 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_X_S 3.118 3.4090 3.61676 3.5200 3.664 8.098
1 colLogSumExps_X_S 3.764 4.0045 5.55832 4.0865 4.246 145.171
expr min lq mean median uq max
2 rowLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.00000
1 colLogSumExps_X_S 1.207184 1.174685 1.536823 1.160937 1.158843 17.92677

Figure: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() on 10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 matrix

> X <- data[["100x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3119648 166.7    5709258 305.0  5709258 305.0
Vcells 5674004  43.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colLogSumExps_X_S = colLogSumExps(X_S, na.rm = FALSE), `colLogSumExps(X, rows, cols)` = colLogSumExps(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colLogSumExps(X[rows, cols])` = colLogSumExps(X[rows, 
+     cols], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3119642 166.7    5709258 305.0  5709258 305.0
Vcells 5684087  43.4   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowLogSumExps_X_S = rowLogSumExps(X_S, na.rm = FALSE), `rowLogSumExps(X, cols, rows)` = rowLogSumExps(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowLogSumExps(X[cols, rows])` = rowLogSumExps(X[cols, 
+     rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() 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 colLogSumExps_X_S 0.073790 0.0751865 0.0770616 0.0756185 0.0764115 0.123131
3 colLogSumExps(X[rows, cols]) 0.089068 0.0908800 0.0935489 0.0915475 0.0924520 0.143024
2 colLogSumExps(X, rows, cols) 0.093300 0.0951985 0.0982020 0.0961655 0.0980385 0.151270
expr min lq mean median uq max
1 colLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 colLogSumExps(X[rows, cols]) 1.207047 1.208728 1.213950 1.210649 1.209923 1.161560
2 colLogSumExps(X, rows, cols) 1.264399 1.266165 1.274331 1.271719 1.283033 1.228529

Table: Benchmarking of rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() 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 rowLogSumExps_X_S 0.072754 0.0741605 0.0755480 0.0749855 0.0754155 0.122683
3 rowLogSumExps(X[cols, rows]) 0.080422 0.0821035 0.0838968 0.0827245 0.0832340 0.143713
2 rowLogSumExps(X, cols, rows) 0.094192 0.0960640 0.0977496 0.0977315 0.0988820 0.110395
expr min lq mean median uq max
1 rowLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
3 rowLogSumExps(X[cols, rows]) 1.105396 1.107106 1.110510 1.103207 1.103672 1.1714174
2 rowLogSumExps(X, cols, rows) 1.294664 1.295353 1.293875 1.303339 1.311163 0.8998394

Figure: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() on 100x100 data as well as rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() 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 rowLogSumExps_X_S 72.754 74.1605 75.54796 74.9855 75.4155 122.683
1 colLogSumExps_X_S 73.790 75.1865 77.06161 75.6185 76.4115 123.131
expr min lq mean median uq max
2 rowLogSumExps_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colLogSumExps_X_S 1.01424 1.013835 1.020036 1.008442 1.013207 1.003652

Figure: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() on 100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 matrix

> X <- data[["1000x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3120402 166.7    5709258 305.0  5709258 305.0
Vcells 5678072  43.4   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colLogSumExps_X_S = colLogSumExps(X_S, na.rm = FALSE), `colLogSumExps(X, rows, cols)` = colLogSumExps(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colLogSumExps(X[rows, cols])` = colLogSumExps(X[rows, 
+     cols], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3120393 166.7    5709258 305.0  5709258 305.0
Vcells 5688150  43.4   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowLogSumExps_X_S = rowLogSumExps(X_S, na.rm = FALSE), `rowLogSumExps(X, cols, rows)` = rowLogSumExps(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowLogSumExps(X[cols, rows])` = rowLogSumExps(X[cols, 
+     rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() 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 colLogSumExps_X_S 0.069243 0.0704195 0.0714223 0.0710575 0.0715130 0.088144
3 colLogSumExps(X[rows, cols]) 0.085083 0.0863280 0.0870049 0.0867995 0.0872350 0.095591
2 colLogSumExps(X, rows, cols) 0.090485 0.0929215 0.0940630 0.0937890 0.0948475 0.127623
expr min lq mean median uq max
1 colLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 colLogSumExps(X[rows, cols]) 1.228760 1.225910 1.218177 1.221539 1.219848 1.084487
2 colLogSumExps(X, rows, cols) 1.306775 1.319542 1.316998 1.319903 1.326297 1.447892

Table: Benchmarking of rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() 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 rowLogSumExps_X_S 0.070077 0.0711640 0.0722343 0.0714890 0.0720495 0.118733
3 rowLogSumExps(X[cols, rows]) 0.079959 0.0811855 0.0819385 0.0816695 0.0823235 0.086993
2 rowLogSumExps(X, cols, rows) 0.091397 0.0931180 0.0948247 0.0942480 0.0954430 0.107894
expr min lq mean median uq max
1 rowLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
3 rowLogSumExps(X[cols, rows]) 1.141016 1.140823 1.134343 1.142407 1.142596 0.7326775
2 rowLogSumExps(X, cols, rows) 1.304237 1.308499 1.312737 1.318357 1.324687 0.9087111

Figure: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() on 1000x10 data as well as rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() 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 colLogSumExps_X_S 69.243 70.4195 71.42226 71.0575 71.5130 88.144
2 rowLogSumExps_X_S 70.077 71.1640 72.23430 71.4890 72.0495 118.733
expr min lq mean median uq max
1 colLogSumExps_X_S 1.000000 1.000000 1.00000 1.000000 1.000000 1.000000
2 rowLogSumExps_X_S 1.012045 1.010572 1.01137 1.006072 1.007502 1.347034

Figure: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() on 1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 matrix

> X <- data[["10x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3120605 166.7    5709258 305.0  5709258 305.0
Vcells 5678994  43.4   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colLogSumExps_X_S = colLogSumExps(X_S, na.rm = FALSE), `colLogSumExps(X, rows, cols)` = colLogSumExps(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colLogSumExps(X[rows, cols])` = colLogSumExps(X[rows, 
+     cols], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3120599 166.7    5709258 305.0  5709258 305.0
Vcells 5689077  43.5   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowLogSumExps_X_S = rowLogSumExps(X_S, na.rm = FALSE), `rowLogSumExps(X, cols, rows)` = rowLogSumExps(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowLogSumExps(X[cols, rows])` = rowLogSumExps(X[cols, 
+     rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() 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 colLogSumExps_X_S 0.089753 0.0912965 0.0931319 0.0920765 0.0929305 0.121068
3 colLogSumExps(X[rows, cols]) 0.099254 0.1011595 0.1025650 0.1017265 0.1029010 0.128791
2 colLogSumExps(X, rows, cols) 0.110992 0.1132805 0.1148021 0.1140350 0.1152220 0.163981
expr min lq mean median uq max
1 colLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 colLogSumExps(X[rows, cols]) 1.105857 1.108033 1.101287 1.104804 1.107290 1.063791
2 colLogSumExps(X, rows, cols) 1.236638 1.240798 1.232683 1.238481 1.239873 1.354454

Table: Benchmarking of rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() 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 rowLogSumExps_X_S 0.087026 0.0887295 0.0907739 0.0895610 0.0904855 0.141141
3 rowLogSumExps(X[cols, rows]) 0.095142 0.0972235 0.0995544 0.0980465 0.0992050 0.162084
2 rowLogSumExps(X, cols, rows) 0.109433 0.1119905 0.1136721 0.1134095 0.1147215 0.123788
expr min lq mean median uq max
1 rowLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 rowLogSumExps(X[cols, rows]) 1.093260 1.095729 1.096730 1.094745 1.096364 1.148384
2 rowLogSumExps(X, cols, rows) 1.257475 1.262156 1.252255 1.266282 1.267844 0.877052

Figure: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() on 10x1000 data as well as rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() 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
2 rowLogSumExps_X_S 87.026 88.7295 90.77390 89.5610 90.4855 141.141
1 colLogSumExps_X_S 89.753 91.2965 93.13193 92.0765 92.9305 121.068
expr min lq mean median uq max
2 rowLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colLogSumExps_X_S 1.031335 1.028931 1.025977 1.028087 1.027021 0.8577805

Figure: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() on 10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 matrix

> X <- data[["100x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3120807 166.7    5709258 305.0  5709258 305.0
Vcells 5723718  43.7   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colLogSumExps_X_S = colLogSumExps(X_S, na.rm = FALSE), `colLogSumExps(X, rows, cols)` = colLogSumExps(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colLogSumExps(X[rows, cols])` = colLogSumExps(X[rows, 
+     cols], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3120798 166.7    5709258 305.0  5709258 305.0
Vcells 5823796  44.5   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowLogSumExps_X_S = rowLogSumExps(X_S, na.rm = FALSE), `rowLogSumExps(X, cols, rows)` = rowLogSumExps(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowLogSumExps(X[cols, rows])` = rowLogSumExps(X[cols, 
+     rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() 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 colLogSumExps_X_S 0.702012 0.7251745 0.7730765 0.7534285 0.8188575 1.108125
3 colLogSumExps(X[rows, cols]) 0.853691 0.8834860 1.0273189 0.9448055 1.0683945 5.588463
2 colLogSumExps(X, rows, cols) 0.910446 0.9540430 1.0488809 1.0386625 1.1324515 1.551972
expr min lq mean median uq max
1 colLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 colLogSumExps(X[rows, cols]) 1.216063 1.218308 1.328871 1.254008 1.304738 5.043170
2 colLogSumExps(X, rows, cols) 1.296909 1.315605 1.356762 1.378581 1.382965 1.400539

Table: Benchmarking of rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() 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 rowLogSumExps_X_S 0.714108 0.7386430 0.8208492 0.761323 0.873566 1.674171
3 rowLogSumExps(X[cols, rows]) 0.789893 0.8133575 1.0386781 0.912627 1.099045 7.761841
2 rowLogSumExps(X, cols, rows) 0.969716 1.0194975 1.1353743 1.040480 1.209656 2.084237
expr min lq mean median uq max
1 rowLogSumExps_X_S 1.000000 1.000000 1.00000 1.000000 1.000000 1.000000
3 rowLogSumExps(X[cols, rows]) 1.106125 1.101151 1.26537 1.198738 1.258114 4.636229
2 rowLogSumExps(X, cols, rows) 1.357940 1.380230 1.38317 1.366673 1.384733 1.244937

Figure: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() on 100x1000 data as well as rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() 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 colLogSumExps_X_S 702.012 725.1745 773.0765 753.4285 818.8575 1108.125
2 rowLogSumExps_X_S 714.108 738.6430 820.8492 761.3230 873.5660 1674.171
expr min lq mean median uq max
1 colLogSumExps_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowLogSumExps_X_S 1.01723 1.018573 1.061795 1.010478 1.066811 1.510814

Figure: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() on 100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 matrix

> X <- data[["1000x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3121020 166.7    5709258 305.0  5709258 305.0
Vcells 5724542  43.7   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colLogSumExps_X_S = colLogSumExps(X_S, na.rm = FALSE), `colLogSumExps(X, rows, cols)` = colLogSumExps(X, 
+     rows = rows, cols = cols, na.rm = FALSE), `colLogSumExps(X[rows, cols])` = colLogSumExps(X[rows, 
+     cols], na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3121014 166.7    5709258 305.0  5709258 305.0
Vcells 5824625  44.5   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowLogSumExps_X_S = rowLogSumExps(X_S, na.rm = FALSE), `rowLogSumExps(X, cols, rows)` = rowLogSumExps(X, 
+     rows = cols, cols = rows, na.rm = FALSE), `rowLogSumExps(X[cols, rows])` = rowLogSumExps(X[cols, 
+     rows], na.rm = FALSE), unit = "ms")

Table: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() 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 colLogSumExps_X_S 0.669550 0.6842555 0.7828316 0.7776545 0.8084675 1.440616
3 colLogSumExps(X[rows, cols]) 0.739653 0.7620625 0.8978445 0.8984255 0.9691950 1.857678
2 colLogSumExps(X, rows, cols) 0.879903 0.9246995 1.1304426 0.9851270 1.1237585 8.453971
expr min lq mean median uq max
1 colLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 colLogSumExps(X[rows, cols]) 1.104702 1.113710 1.146919 1.155302 1.198805 1.289502
2 colLogSumExps(X, rows, cols) 1.314171 1.351395 1.444043 1.266793 1.389986 5.868303

Table: Benchmarking of rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() 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 rowLogSumExps_X_S 0.67819 0.7022890 0.7529331 0.728701 0.7984225 0.872178
3 rowLogSumExps(X[cols, rows]) 0.76249 0.7813575 0.8587944 0.795139 0.9697080 1.061498
2 rowLogSumExps(X, cols, rows) 0.93035 0.9803455 1.1362143 1.022622 1.1532995 8.243347
expr min lq mean median uq max
1 rowLogSumExps_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 rowLogSumExps(X[cols, rows]) 1.124301 1.112587 1.140599 1.091173 1.214530 1.217066
2 rowLogSumExps(X, cols, rows) 1.371813 1.395929 1.509051 1.403349 1.444473 9.451450

Figure: Benchmarking of colLogSumExps_X_S(), colLogSumExps(X, rows, cols)() and colLogSumExps(X[rows, cols])() on 1000x100 data as well as rowLogSumExps_X_S(), rowLogSumExps(X, cols, rows)() and rowLogSumExps(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() 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
2 rowLogSumExps_X_S 678.19 702.2890 752.9331 728.7010 798.4225 872.178
1 colLogSumExps_X_S 669.55 684.2555 782.8316 777.6545 808.4675 1440.616
expr min lq mean median uq max
2 rowLogSumExps_X_S 1.0000000 1.0000000 1.000000 1.000000 1.000000 1.000000
1 colLogSumExps_X_S 0.9872602 0.9743218 1.039709 1.067179 1.012581 1.651745

Figure: Benchmarking of colLogSumExps_X_S() and rowLogSumExps_X_S() on 1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Appendix

Session information

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 12.69 secs.

Reproducibility

To reproduce this report, do:

html <- matrixStats:::benchmark('colRowLogSumExps_subset')

Copyright Dongcan Jiang. Last updated on 2019-09-10 20:41:05 (-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>
⚠️ **GitHub.com Fallback** ⚠️