Skip to content
Henrik Bengtsson edited this page Sep 11, 2019 · 3 revisions

matrixStats: Benchmark report


colAnys() and rowAnys() benchmarks on subsetted computation

This report benchmark the performance of colAnys() and rowAnys() 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 = "logical")

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 3103114 165.8    4823098 257.6  4823098 257.6
Vcells 5671569  43.3   18742341 143.0 61159414 466.7
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3102042 165.7    4823098 257.6  4823098 257.6
Vcells 5668799  43.3   18742341 143.0 61159414 466.7
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(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 colAnys_X_S 0.001305 0.0013490 0.0016595 0.001402 0.0015125 0.022670
2 colAnys(X, rows, cols) 0.001465 0.0015175 0.0016257 0.001567 0.0016540 0.004061
3 colAnys(X[rows, cols]) 0.001953 0.0022165 0.0023833 0.002286 0.0023820 0.008481
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colAnys(X, rows, cols) 1.122605 1.124907 0.9796386 1.117689 1.093554 0.1791354
3 colAnys(X[rows, cols]) 1.496552 1.643069 1.4361528 1.630528 1.574876 0.3741067
Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(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 rowAnys_X_S 0.001292 0.0013420 0.0014290 0.001371 0.0014530 0.003316
2 rowAnys(X, cols, rows) 0.001475 0.0015315 0.0019527 0.001583 0.0016785 0.034527
3 rowAnys(X[cols, rows]) 0.001841 0.0021350 0.0022718 0.002181 0.0022945 0.006839
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys(X, cols, rows) 1.141641 1.141207 1.366506 1.154632 1.155196 10.412244
3 rowAnys(X[cols, rows]) 1.424923 1.590909 1.589777 1.590810 1.579147 2.062425
Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 10x10 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_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 rowAnys_X_S 1.292 1.342 1.42898 1.371 1.4530 3.316
1 colAnys_X_S 1.305 1.349 1.65951 1.402 1.5125 22.670
expr min lq mean median uq max
2 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.00000 1.00000
1 colAnys_X_S 1.010062 1.005216 1.161325 1.022611 1.04095 6.83655
Figure: Benchmarking of colAnys_X_S() and rowAnys_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 3100592 165.6    4823098 257.6  4823098 257.6
Vcells 5336926  40.8   18742341 143.0 61159414 466.7
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3100586 165.6    4823098 257.6  4823098 257.6
Vcells 5342009  40.8   18742341 143.0 61159414 466.7
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(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 colAnys_X_S 0.001906 0.002213 0.0024157 0.0023430 0.0025245 0.005047
2 colAnys(X, rows, cols) 0.002290 0.002573 0.0029221 0.0027445 0.0029885 0.011148
3 colAnys(X[rows, cols]) 0.017392 0.017816 0.0190385 0.0179830 0.0181980 0.057043
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colAnys(X, rows, cols) 1.201469 1.162675 1.209619 1.171361 1.183799 2.208837
3 colAnys(X[rows, cols]) 9.124869 8.050610 7.881095 7.675203 7.208556 11.302358
Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(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 rowAnys_X_S 0.004509 0.0047755 0.0049708 0.004896 0.0050290 0.008161
2 rowAnys(X, cols, rows) 0.004857 0.0052085 0.0053674 0.005331 0.0054375 0.007504
3 rowAnys(X[cols, rows]) 0.011920 0.0122635 0.0131430 0.012422 0.0126040 0.061899
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.077179 1.090671 1.079782 1.088848 1.081229 0.9194952
3 rowAnys(X[cols, rows]) 2.643602 2.568003 2.644058 2.537173 2.506264 7.5847323
Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 100x100 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_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
1 colAnys_X_S 1.906 2.2130 2.41572 2.343 2.5245 5.047
2 rowAnys_X_S 4.509 4.7755 4.97078 4.896 5.0290 8.161
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.00000 1.000000 1.000000 1.000000 1.000
2 rowAnys_X_S 2.365687 2.15793 2.057681 2.089629 1.992078 1.617
Figure: Benchmarking of colAnys_X_S() and rowAnys_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 3101344 165.7    4823098 257.6  4823098 257.6
Vcells 5340992  40.8   18742341 143.0 61159414 466.7
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3101338 165.7    4823098 257.6  4823098 257.6
Vcells 5346075  40.8   18742341 143.0 61159414 466.7
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(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 colAnys_X_S 0.001333 0.0014020 0.0018005 0.0014970 0.0016155 0.010111
2 colAnys(X, rows, cols) 0.002059 0.0021775 0.0032207 0.0023085 0.0024280 0.029217
3 colAnys(X[rows, cols]) 0.015924 0.0168000 0.0201644 0.0169285 0.0171755 0.106120
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.00000 1.000000
2 colAnys(X, rows, cols) 1.544636 1.553138 1.788734 1.542084 1.50294 2.889625
3 colAnys(X[rows, cols]) 11.945987 11.982882 11.199164 11.308283 10.63169 10.495500
Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(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 rowAnys_X_S 0.004797 0.0051965 0.0056545 0.0053410 0.0055050 0.035472
2 rowAnys(X, cols, rows) 0.005285 0.0054650 0.0056345 0.0055605 0.0057075 0.010916
3 rowAnys(X[cols, rows]) 0.013819 0.0143980 0.0150778 0.0146970 0.0148815 0.033566
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.101730 1.051669 0.9964506 1.041097 1.036785 0.3077357
3 rowAnys(X[cols, rows]) 2.880759 2.770711 2.6664963 2.751732 2.703270 0.9462675
Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 1000x10 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_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 colAnys_X_S 1.333 1.4020 1.80053 1.497 1.6155 10.111
2 rowAnys_X_S 4.797 5.1965 5.65454 5.341 5.5050 35.472
expr min lq mean median uq max
1 colAnys_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys_X_S 3.59865 3.706491 3.140486 3.567802 3.407614 3.508258
Figure: Benchmarking of colAnys_X_S() and rowAnys_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 3101550 165.7    4823098 257.6  4823098 257.6
Vcells 5341797  40.8   18742341 143.0 61159414 466.7
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3101544 165.7    4823098 257.6  4823098 257.6
Vcells 5346880  40.8   18742341 143.0 61159414 466.7
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(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 colAnys_X_S 0.005221 0.0057590 0.0065432 0.0061285 0.006483 0.042371
2 colAnys(X, rows, cols) 0.008211 0.0094225 0.0102840 0.0100160 0.010651 0.023703
3 colAnys(X[rows, cols]) 0.014338 0.0149465 0.0158671 0.0154315 0.015782 0.031641
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 colAnys(X, rows, cols) 1.572687 1.636135 1.571699 1.634331 1.642912 0.5594156
3 colAnys(X[rows, cols]) 2.746217 2.595329 2.424964 2.517990 2.434367 0.7467608
Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(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 rowAnys_X_S 0.009220 0.0099475 0.0110537 0.0104010 0.0109665 0.048314
2 rowAnys(X, cols, rows) 0.010392 0.0118965 0.0126637 0.0125045 0.0130695 0.020191
3 rowAnys(X[cols, rows]) 0.016750 0.0177845 0.0188319 0.0183330 0.0189390 0.038611
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.127115 1.195929 1.145653 1.202240 1.191766 0.4179120
3 rowAnys(X[cols, rows]) 1.816703 1.787836 1.703676 1.762619 1.726987 0.7991679
Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 10x1000 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_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
1 colAnys_X_S 5.221 5.7590 6.54323 6.1285 6.4830 42.371
2 rowAnys_X_S 9.220 9.9475 11.05366 10.4010 10.9665 48.314
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys_X_S 1.765945 1.727296 1.689328 1.697153 1.691578 1.140261
Figure: Benchmarking of colAnys_X_S() and rowAnys_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 3101749 165.7    4823098 257.6  4823098 257.6
Vcells 5364441  41.0   18742341 143.0 61159414 466.7
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3101743 165.7    4823098 257.6  4823098 257.6
Vcells 5414524  41.4   18742341 143.0 61159414 466.7
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(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 colAnys_X_S 0.005964 0.0073925 0.0088661 0.0082775 0.0091140 0.019756
2 colAnys(X, rows, cols) 0.010998 0.0133480 0.0149118 0.0142575 0.0153315 0.026915
3 colAnys(X[rows, cols]) 0.157643 0.1754560 0.1877240 0.1861670 0.1926820 0.278515
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.00000 1.000000 1.000000
2 colAnys(X, rows, cols) 1.844064 1.805614 1.681892 1.72244 1.682192 1.362371
3 colAnys(X[rows, cols]) 26.432428 23.734325 21.173286 22.49073 21.141321 14.097743
Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(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 rowAnys_X_S 0.035299 0.0393190 0.0401875 0.0402610 0.0407755 0.069281
2 rowAnys(X, cols, rows) 0.034283 0.0395830 0.0411409 0.0409925 0.0422180 0.058010
3 rowAnys(X[cols, rows]) 0.100286 0.1129605 0.1156707 0.1155745 0.1175915 0.150971
expr min lq mean median uq max
1 rowAnys_X_S 1.0000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 0.9712173 1.006714 1.023724 1.018169 1.035377 0.8373147
3 rowAnys(X[cols, rows]) 2.8410437 2.872924 2.878272 2.870632 2.883876 2.1791112
Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 100x1000 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_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 colAnys_X_S 5.964 7.3925 8.86608 8.2775 9.1140 19.756
2 rowAnys_X_S 35.299 39.3190 40.18753 40.2610 40.7755 69.281
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowAnys_X_S 5.918679 5.318769 4.532728 4.863908 4.473941 3.506833
Figure: Benchmarking of colAnys_X_S() and rowAnys_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 3101961 165.7    4823098 257.6  4823098 257.6
Vcells 5365103  41.0   18742341 143.0 61159414 466.7
> colStats <- microbenchmark(colAnys_X_S = colAnys(X_S), `colAnys(X, rows, cols)` = colAnys(X, rows = rows, 
+     cols = cols), `colAnys(X[rows, cols])` = colAnys(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3101955 165.7    4823098 257.6  4823098 257.6
Vcells 5415186  41.4   18742341 143.0 61159414 466.7
> rowStats <- microbenchmark(rowAnys_X_S = rowAnys(X_S), `rowAnys(X, cols, rows)` = rowAnys(X, rows = cols, 
+     cols = rows), `rowAnys(X[cols, rows])` = rowAnys(X[cols, rows]), unit = "ms")

Table: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(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 colAnys_X_S 0.001995 0.0025625 0.0028477 0.0028200 0.0029805 0.005974
2 colAnys(X, rows, cols) 0.003044 0.0035970 0.0039709 0.0039195 0.0042015 0.008150
3 colAnys(X[rows, cols]) 0.067996 0.0721180 0.0758151 0.0756520 0.0767555 0.159451
expr min lq mean median uq max
1 colAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colAnys(X, rows, cols) 1.525815 1.403707 1.394423 1.389894 1.409663 1.364245
3 colAnys(X[rows, cols]) 34.083208 28.143610 26.623009 26.826950 25.752558 26.690827
Table: Benchmarking of rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(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 rowAnys_X_S 0.029286 0.0331235 0.0340439 0.0344170 0.0348965 0.047718
2 rowAnys(X, cols, rows) 0.029751 0.0332825 0.0340534 0.0344730 0.0352025 0.035944
3 rowAnys(X[cols, rows]) 0.097496 0.1094680 0.1131570 0.1131565 0.1159460 0.198368
expr min lq mean median uq max
1 rowAnys_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowAnys(X, cols, rows) 1.015878 1.004800 1.000280 1.001627 1.008769 0.7532587
3 rowAnys(X[cols, rows]) 3.329099 3.304844 3.323854 3.287808 3.322568 4.1570896
Figure: Benchmarking of colAnys_X_S(), colAnys(X, rows, cols)() and colAnys(X[rows, cols])() on 1000x100 data as well as rowAnys_X_S(), rowAnys(X, cols, rows)() and rowAnys(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colAnys_X_S() and rowAnys_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
1 colAnys_X_S 1.995 2.5625 2.84773 2.820 2.9805 5.974
2 rowAnys_X_S 29.286 33.1235 34.04390 34.417 34.8965 47.718
expr min lq mean median uq max
1 colAnys_X_S 1.0000 1.00000 1.00000 1.00000 1.00000 1.000000
2 rowAnys_X_S 14.6797 12.92624 11.95475 12.20461 11.70827 7.987613
Figure: Benchmarking of colAnys_X_S() and rowAnys_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] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] genefilter_1.66.0       laeken_0.5.0            ergm_3.10.4            
 [4] network_1.15            cwhmisc_6.6             lattice_0.20-38        
 [7] microbenchmark_1.4-6    matrixStats_0.55.0-9000 ggplot2_3.2.1          
[10] knitr_1.24              R.devices_2.16.0        R.utils_2.9.0          
[13] 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] assertthat_0.2.1     highr_0.8            stats4_3.6.1        
 [7] blob_1.2.0           robustbase_0.93-5    pillar_1.4.2        
[10] RSQLite_2.1.2        backports_1.1.4      glue_1.3.1          
[13] digest_0.6.20        colorspace_1.4-1     sandwich_2.5-1      
[16] Matrix_1.2-17        XML_3.98-1.20        lpSolve_5.6.13.3    
[19] pkgconfig_2.0.2      purrr_0.3.2          xtable_1.8-4        
[22] mvtnorm_1.0-11       scales_1.0.0         tibble_2.1.3        
[25] annotate_1.62.0      IRanges_2.18.2       TH.data_1.0-10      
[28] withr_2.1.2          BiocGenerics_0.30.0  lazyeval_0.2.2      
[31] mime_0.7             survival_2.44-1.1    magrittr_1.5        
[34] crayon_1.3.4         statnet.common_4.3.0 memoise_1.1.0       
[37] R.cache_0.13.0       MASS_7.3-51.4        R.rsp_0.43.1        
[40] tools_3.6.1          multcomp_1.4-10      S4Vectors_0.22.1    
[43] trust_0.1-7          munsell_0.5.0        AnnotationDbi_1.46.1
[46] compiler_3.6.1       rlang_0.4.0          RCurl_1.95-4.12     
[49] rappdirs_0.3.1       labeling_0.3         bitops_1.0-6        
[52] base64enc_0.1-3      boot_1.3-23          gtable_0.3.0        
[55] codetools_0.2-16     DBI_1.0.0            markdown_1.1        
[58] R6_2.4.0             zoo_1.8-6            dplyr_0.8.3         
[61] bit_1.1-14           zeallot_0.1.0        parallel_3.6.1      
[64] Rcpp_1.0.2           vctrs_0.2.0          DEoptimR_1.0-8      
[67] tidyselect_0.2.5     xfun_0.9             coda_0.19-3         

Total processing time was 12.23 secs.

Reproducibility

To reproduce this report, do:

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

Copyright Dongcan Jiang. Last updated on 2019-09-10 14:58:29 (-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>
Clone this wiki locally