colRowCummins_subset - HenrikBengtsson/matrixStats GitHub Wiki

matrixStats: Benchmark report


colCummins() and rowCummins() benchmarks on subsetted computation

This report benchmark the performance of colCummins() and rowCummins() on subsetted computation.

Data type "integer"

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 = mode)

Results

10x10 integer 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 3090639 165.1    5709258 305.0  5709258 305.0
Vcells 5672763  43.3   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3089802 165.1    5709258 305.0  5709258 305.0
Vcells 5670704  43.3   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.000915 0.0011200 0.0020594 0.0011585 0.0012545 0.087488
2 colCummins(X, rows, cols) 0.001005 0.0012505 0.0013654 0.0013000 0.0013705 0.003372
3 colCummins(X[rows, cols]) 0.001464 0.0018135 0.0019923 0.0018775 0.0019910 0.007840
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colCummins(X, rows, cols) 1.098361 1.116518 0.6630216 1.122141 1.092467 0.0385424
3 colCummins(X[rows, cols]) 1.600000 1.619196 0.9674272 1.620630 1.587087 0.0896123

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on integer+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 rowCummins_X_S 0.000892 0.0011295 0.0012449 0.0012010 0.0012865 0.002965
2 rowCummins(X, cols, rows) 0.001068 0.0013020 0.0022825 0.0013585 0.0014870 0.087982
3 rowCummins(X[cols, rows]) 0.001428 0.0018735 0.0020410 0.0019480 0.0020875 0.006222
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.197309 1.152722 1.833494 1.131141 1.155849 29.673524
3 rowCummins(X[cols, rows]) 1.600897 1.658699 1.639499 1.621982 1.622620 2.098482

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+10x10 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 915 1120.0 2059.39 1158.5 1254.5 87488
2 rowCummins_X_S 892 1129.5 1244.88 1201.0 1286.5 2965
expr min lq mean median uq max
1 colCummins_X_S 1.0000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 rowCummins_X_S 0.9748634 1.008482 0.6044897 1.036685 1.025508 0.0338904

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 integer 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 3088406 165.0    5709258 305.0  5709258 305.0
Vcells 5339262  40.8   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3088400 165.0    5709258 305.0  5709258 305.0
Vcells 5344345  40.8   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.008817 0.0089450 0.0091459 0.0090645 0.0091840 0.010996
2 colCummins(X, rows, cols) 0.008903 0.0094100 0.0096303 0.0095285 0.0096700 0.014627
3 colCummins(X[rows, cols]) 0.016285 0.0165575 0.0176355 0.0166755 0.0169095 0.062493
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colCummins(X, rows, cols) 1.009754 1.051984 1.052970 1.051189 1.052918 1.330211
3 colCummins(X[rows, cols]) 1.847000 1.851034 1.928245 1.839649 1.841191 5.683249

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on integer+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 rowCummins_X_S 0.006658 0.006922 0.0071410 0.0069905 0.0071210 0.011277
2 rowCummins(X, cols, rows) 0.009422 0.009656 0.0098793 0.0097885 0.0099240 0.013185
3 rowCummins(X[cols, rows]) 0.013913 0.014320 0.0153660 0.0144620 0.0147095 0.056003
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.415140 1.394973 1.383452 1.400257 1.393625 1.169194
3 rowCummins(X[cols, rows]) 2.089667 2.068766 2.151796 2.068808 2.065651 4.966126

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+100x100 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+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 rowCummins_X_S 6.658 6.922 7.14102 6.9905 7.121 11.277
1 colCummins_X_S 8.817 8.945 9.14588 9.0645 9.184 10.996
expr min lq mean median uq max
2 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 1.324272 1.292257 1.280753 1.296688 1.289707 0.975082

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 integer 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 3089161 165.0    5709258 305.0  5709258 305.0
Vcells 5343331  40.8   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3089152 165.0    5709258 305.0  5709258 305.0
Vcells 5348409  40.9   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.009516 0.009839 0.0144038 0.0102400 0.0119245 0.092255
2 colCummins(X, rows, cols) 0.009938 0.010439 0.0140314 0.0109305 0.0124975 0.056128
3 colCummins(X[rows, cols]) 0.017062 0.017640 0.0224640 0.0183595 0.0202485 0.083665
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000
2 colCummins(X, rows, cols) 1.044346 1.060982 0.9741436 1.067432 1.048052 0.6084006
3 colCummins(X[rows, cols]) 1.792980 1.792865 1.5595930 1.792920 1.698059 0.9068885

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on integer+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 rowCummins_X_S 0.007483 0.0077385 0.0080536 0.0078480 0.0080045 0.023165
2 rowCummins(X, cols, rows) 0.010802 0.0110445 0.0114086 0.0111635 0.0112805 0.024163
3 rowCummins(X[cols, rows]) 0.015721 0.0162440 0.0165020 0.0164440 0.0166240 0.019230
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowCummins(X, cols, rows) 1.443539 1.427215 1.416593 1.422464 1.409270 1.0430822
3 rowCummins(X[cols, rows]) 2.100895 2.099115 2.049028 2.095311 2.076832 0.8301317

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+1000x10 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+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
2 rowCummins_X_S 7.483 7.7385 8.05357 7.848 8.0045 23.165
1 colCummins_X_S 9.516 9.8390 14.40379 10.240 11.9245 92.255
expr min lq mean median uq max
2 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 1.271683 1.271435 1.788498 1.304791 1.489724 3.982517

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 integer 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 3089365 165.0    5709258 305.0  5709258 305.0
Vcells 5344164  40.8   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3089359 165.0    5709258 305.0  5709258 305.0
Vcells 5349247  40.9   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.007207 0.0075985 0.0078169 0.007738 0.007888 0.010273
2 colCummins(X, rows, cols) 0.010152 0.0104300 0.0109617 0.010522 0.010641 0.048803
3 colCummins(X[rows, cols]) 0.015761 0.0162120 0.0166486 0.016348 0.016583 0.021429
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colCummins(X, rows, cols) 1.408630 1.372639 1.402308 1.359783 1.349011 4.750608
3 colCummins(X[rows, cols]) 2.186902 2.133579 2.129825 2.112691 2.102307 2.085954

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on integer+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 rowCummins_X_S 0.006360 0.0067120 0.0070464 0.0068140 0.0069870 0.022598
2 rowCummins(X, cols, rows) 0.009311 0.0096670 0.0101872 0.0097940 0.0099915 0.040024
3 rowCummins(X[cols, rows]) 0.013739 0.0140725 0.0144666 0.0142395 0.0143875 0.022746
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.463994 1.440256 1.445744 1.437335 1.430013 1.771130
3 rowCummins(X[cols, rows]) 2.160220 2.096618 2.053050 2.089742 2.059181 1.006549

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+10x1000 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+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 rowCummins_X_S 6.360 6.7120 7.04637 6.814 6.987 22.598
1 colCummins_X_S 7.207 7.5985 7.81690 7.738 7.888 10.273
expr min lq mean median uq max
2 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colCummins_X_S 1.133176 1.132077 1.109351 1.135603 1.128954 0.4545978

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 integer 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 3089564 165.1    5709258 305.0  5709258 305.0
Vcells 5366821  41.0   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3089558 165.1    5709258 305.0  5709258 305.0
Vcells 5416904  41.4   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.076467 0.0830405 0.0854113 0.0857135 0.0881830 0.100931
2 colCummins(X, rows, cols) 0.078039 0.0821825 0.0868152 0.0869735 0.0899560 0.159013
3 colCummins(X[rows, cols]) 0.148192 0.1563745 0.1632731 0.1648780 0.1696205 0.192752
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.0000000 1.000000 1.000000 1.000000 1.000000
2 colCummins(X, rows, cols) 1.020558 0.9896677 1.016437 1.014700 1.020106 1.575462
3 colCummins(X[rows, cols]) 1.937986 1.8831113 1.911610 1.923594 1.923506 1.909740

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on integer+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 rowCummins_X_S 0.053342 0.059001 0.0611612 0.0611045 0.0629900 0.077378
2 rowCummins(X, cols, rows) 0.078537 0.087337 0.0911573 0.0915950 0.0953395 0.110285
3 rowCummins(X[cols, rows]) 0.113550 0.129148 0.1328198 0.1328050 0.1368540 0.176294
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.472330 1.480263 1.490444 1.498989 1.513566 1.425276
3 rowCummins(X[cols, rows]) 2.128717 2.188912 2.171637 2.173408 2.172631 2.278348

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+100x1000 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+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 rowCummins_X_S 53.342 59.0010 61.16116 61.1045 62.990 77.378
1 colCummins_X_S 76.467 83.0405 85.41129 85.7135 88.183 100.931
expr min lq mean median uq max
2 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 1.433523 1.407442 1.396496 1.402736 1.399952 1.304389

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 integer 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 3089780 165.1    5709258 305.0  5709258 305.0
Vcells 5367600  41.0   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3089774 165.1    5709258 305.0  5709258 305.0
Vcells 5417683  41.4   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
2 colCummins(X, rows, cols) 0.075888 0.0872800 0.0907698 0.090959 0.0939045 0.112488
1 colCummins_X_S 0.079572 0.0886955 0.0915477 0.093005 0.0939690 0.124616
3 colCummins(X[rows, cols]) 0.141785 0.1566385 0.1629022 0.164924 0.1698225 0.226106
expr min lq mean median uq max
2 colCummins(X, rows, cols) 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 1.048545 1.016218 1.008570 1.022494 1.000687 1.107816
3 colCummins(X[rows, cols]) 1.868345 1.794667 1.794675 1.813169 1.808460 2.010045

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on integer+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 rowCummins_X_S 0.053851 0.0583935 0.0606016 0.061617 0.0634515 0.076102
2 rowCummins(X, cols, rows) 0.082936 0.0898645 0.0936903 0.095209 0.0979100 0.113070
3 rowCummins(X[cols, rows]) 0.124949 0.1345165 0.1403937 0.139218 0.1464985 0.207243
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.540101 1.538947 1.546003 1.545174 1.543068 1.485769
3 rowCummins(X[cols, rows]) 2.320273 2.303621 2.316664 2.259409 2.308826 2.723227

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on integer+1000x100 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+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 rowCummins_X_S 53.851 58.3935 60.60165 61.617 63.4515 76.102
1 colCummins_X_S 79.572 88.6955 91.54767 93.005 93.9690 124.616
expr min lq mean median uq max
2 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 1.477633 1.518928 1.510647 1.509405 1.480958 1.637487

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on integer+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Data type "double"

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 = mode)

Results

10x10 double 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 3089998 165.1    5709258 305.0  5709258 305.0
Vcells 5458701  41.7   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3089983 165.1    5709258 305.0  5709258 305.0
Vcells 5458869  41.7   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.001000 0.0011030 0.0013316 0.0011535 0.0012200 0.013730
2 colCummins(X, rows, cols) 0.001066 0.0012855 0.0014034 0.0013530 0.0014130 0.003784
3 colCummins(X[rows, cols]) 0.001783 0.0018970 0.0020751 0.0019650 0.0020755 0.006815
expr min lq mean median uq max
1 colCummins_X_S 1.000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 colCummins(X, rows, cols) 1.066 1.165458 1.053920 1.172952 1.158197 0.2756009
3 colCummins(X[rows, cols]) 1.783 1.719855 1.558351 1.703511 1.701229 0.4963583

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on double+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 rowCummins_X_S 0.000966 0.0011765 0.0013011 0.0012325 0.0013325 0.003136
2 rowCummins(X, cols, rows) 0.001125 0.0013525 0.0017580 0.0014185 0.0015595 0.031579
3 rowCummins(X[cols, rows]) 0.001450 0.0018975 0.0020451 0.0019860 0.0020825 0.005927
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.164596 1.149596 1.351182 1.150913 1.170357 10.069834
3 rowCummins(X[cols, rows]) 1.501035 1.612835 1.571821 1.611359 1.562852 1.889987

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+10x10 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 1000 1103.0 1331.60 1153.5 1220.0 13730
2 rowCummins_X_S 966 1176.5 1301.09 1232.5 1332.5 3136
expr min lq mean median uq max
1 colCummins_X_S 1.000 1.000000 1.0000000 1.000000 1.000000 1.000000
2 rowCummins_X_S 0.966 1.066636 0.9770877 1.068487 1.092213 0.228405

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 double 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 3090200 165.1    5709258 305.0  5709258 305.0
Vcells 5464651  41.7   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3090194 165.1    5709258 305.0  5709258 305.0
Vcells 5474734  41.8   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.010794 0.0115485 0.0117035 0.0117080 0.0118150 0.013680
2 colCummins(X, rows, cols) 0.011887 0.0121600 0.0129274 0.0123665 0.0125200 0.044043
3 colCummins(X[rows, cols]) 0.026945 0.0272420 0.0282785 0.0274560 0.0276965 0.069881
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colCummins(X, rows, cols) 1.101260 1.052951 1.104575 1.056244 1.059670 3.219517
3 colCummins(X[rows, cols]) 2.496294 2.358921 2.416242 2.345063 2.344181 5.108260

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on double+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 rowCummins_X_S 0.006163 0.0065905 0.0070962 0.0070745 0.0073915 0.011508
2 rowCummins(X, cols, rows) 0.008060 0.0088115 0.0092377 0.0090880 0.0093710 0.015023
3 rowCummins(X[cols, rows]) 0.013431 0.0141430 0.0155416 0.0148875 0.0153165 0.055384
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.307805 1.337000 1.301787 1.284614 1.267808 1.305440
3 rowCummins(X[cols, rows]) 2.179296 2.145968 2.190137 2.104389 2.072178 4.812652

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+100x100 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+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 rowCummins_X_S 6.163 6.5905 7.0962 7.0745 7.3915 11.508
1 colCummins_X_S 10.794 11.5485 11.7035 11.7080 11.8150 13.680
expr min lq mean median uq max
2 rowCummins_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 1.75142 1.752295 1.649263 1.654958 1.598458 1.188738

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 double 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 3090409 165.1    5709258 305.0  5709258 305.0
Vcells 5466061  41.8   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3090403 165.1    5709258 305.0  5709258 305.0
Vcells 5476144  41.8   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
2 colCummins(X, rows, cols) 0.009985 0.010337 0.0110026 0.0105045 0.010664 0.050924
1 colCummins_X_S 0.012504 0.012787 0.0129902 0.0128800 0.013055 0.015821
3 colCummins(X[rows, cols]) 0.028160 0.028511 0.0293906 0.0286435 0.028841 0.060066
expr min lq mean median uq max
2 colCummins(X, rows, cols) 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
1 colCummins_X_S 1.252278 1.237013 1.180650 1.226141 1.224212 0.3106787
3 colCummins(X[rows, cols]) 2.820230 2.758150 2.671245 2.726784 2.704520 1.1795224

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on double+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 rowCummins_X_S 0.006328 0.0070205 0.0077093 0.0072965 0.007725 0.038172
2 rowCummins(X, cols, rows) 0.010371 0.0110405 0.0117670 0.0112185 0.011381 0.041706
3 rowCummins(X[cols, rows]) 0.015277 0.0161325 0.0169096 0.0167285 0.017206 0.022217
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000
2 rowCummins(X, cols, rows) 1.638906 1.572609 1.526340 1.537518 1.473269 1.0925809
3 rowCummins(X[cols, rows]) 2.414191 2.297913 2.193406 2.292675 2.227314 0.5820235

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+1000x10 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+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
2 rowCummins_X_S 6.328 7.0205 7.70927 7.2965 7.725 38.172
1 colCummins_X_S 12.504 12.7870 12.99022 12.8800 13.055 15.821
expr min lq mean median uq max
2 rowCummins_X_S 1.00000 1.00000 1.000000 1.00000 1.000000 1.0000000
1 colCummins_X_S 1.97598 1.82138 1.685013 1.76523 1.689968 0.4144661

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 double 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 3090617 165.1    5709258 305.0  5709258 305.0
Vcells 5466214  41.8   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3090611 165.1    5709258 305.0  5709258 305.0
Vcells 5476297  41.8   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.006549 0.0069285 0.0077187 0.0071435 0.007417 0.039536
3 colCummins(X[rows, cols]) 0.015572 0.0160515 0.0173967 0.0163745 0.016966 0.040929
2 colCummins(X, rows, cols) 0.019225 0.0206570 0.0220200 0.0210320 0.021633 0.060253
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 colCummins(X[rows, cols]) 2.377768 2.316735 2.253848 2.292224 2.287448 1.035234
2 colCummins(X, rows, cols) 2.935563 2.981453 2.852822 2.944215 2.916678 1.524003

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on double+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 rowCummins_X_S 0.005511 0.0062450 0.0081672 0.0072000 0.0078260 0.035589
2 rowCummins(X, cols, rows) 0.008481 0.0089305 0.0110507 0.0093655 0.0098825 0.038541
3 rowCummins(X[cols, rows]) 0.013547 0.0141680 0.0178240 0.0151260 0.0164585 0.077312
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.538922 1.430024 1.353054 1.300764 1.262778 1.082947
3 rowCummins(X[cols, rows]) 2.458175 2.268695 2.182383 2.100833 2.103054 2.172357

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+10x1000 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+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 colCummins_X_S 6.549 6.9285 7.71868 7.1435 7.417 39.536
2 rowCummins_X_S 5.511 6.2450 8.16724 7.2000 7.826 35.589
expr min lq mean median uq max
1 colCummins_X_S 1.0000000 1.0000000 1.000000 1.000000 1.000000 1.0000000
2 rowCummins_X_S 0.8415025 0.9013495 1.058114 1.007909 1.055144 0.9001669

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 double 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 3090816 165.1    5709258 305.0  5709258 305.0
Vcells 5511653  42.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3090810 165.1    5709258 305.0  5709258 305.0
Vcells 5611736  42.9   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
1 colCummins_X_S 0.103606 0.1067355 0.1181058 0.1123055 0.1151725 0.233231
2 colCummins(X, rows, cols) 0.116474 0.1203700 0.1657188 0.1261345 0.1297305 3.841325
3 colCummins(X[rows, cols]) 0.250403 0.2578555 0.2767217 0.2711595 0.2787135 0.505991
expr min lq mean median uq max
1 colCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 colCummins(X, rows, cols) 1.124201 1.127741 1.403138 1.123137 1.126402 16.470045
3 colCummins(X[rows, cols]) 2.416877 2.415836 2.342999 2.414481 2.419966 2.169484

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on double+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 rowCummins_X_S 0.043556 0.0461445 0.0491090 0.0478995 0.0493110 0.103283
2 rowCummins(X, cols, rows) 0.069261 0.0718465 0.0771819 0.0753845 0.0775475 0.140702
3 rowCummins(X[cols, rows]) 0.115165 0.1203045 0.1656451 0.1251505 0.1321620 3.890879
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.590160 1.556990 1.571644 1.573806 1.572621 1.362296
3 rowCummins(X[cols, rows]) 2.644067 2.607125 3.373008 2.612773 2.680173 37.672018

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+100x1000 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+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 rowCummins_X_S 43.556 46.1445 49.10901 47.8995 49.3110 103.283
1 colCummins_X_S 103.606 106.7355 118.10581 112.3055 115.1725 233.231
expr min lq mean median uq max
2 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 2.378685 2.313071 2.404972 2.344607 2.335635 2.258174

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 double 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 3091032 165.1    5709258 305.0  5709258 305.0
Vcells 5511800  42.1   22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colCummins_X_S = colCummins(X_S), `colCummins(X, rows, cols)` = colCummins(X, 
+     rows = rows, cols = cols), `colCummins(X[rows, cols])` = colCummins(X[rows, cols]), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
          used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells 3091026 165.1    5709258 305.0  5709258 305.0
Vcells 5611883  42.9   22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowCummins_X_S = rowCummins(X_S), `rowCummins(X, cols, rows)` = rowCummins(X, 
+     rows = cols, cols = rows), `rowCummins(X[cols, rows])` = rowCummins(X[cols, rows]), unit = "ms")

Table: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.

expr min lq mean median uq max
2 colCummins(X, rows, cols) 0.085969 0.087311 0.0944244 0.0902540 0.0927465 0.180366
1 colCummins_X_S 0.115069 0.115867 0.1604314 0.1187300 0.1252880 3.831997
3 colCummins(X[rows, cols]) 0.182433 0.184391 0.1987310 0.1919055 0.2052675 0.393272
expr min lq mean median uq max
2 colCummins(X, rows, cols) 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
1 colCummins_X_S 1.338494 1.327061 1.699047 1.315510 1.350865 21.245673
3 colCummins(X[rows, cols]) 2.122079 2.111887 2.104659 2.126282 2.213210 2.180411

Table: Benchmarking of rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on double+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 rowCummins_X_S 0.050629 0.0531730 0.0553793 0.0543600 0.0553780 0.077377
2 rowCummins(X, cols, rows) 0.074757 0.0767525 0.1178996 0.0797375 0.0814075 3.911088
3 rowCummins(X[cols, rows]) 0.125052 0.1288805 0.1354009 0.1328720 0.1363755 0.263710
expr min lq mean median uq max
1 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
2 rowCummins(X, cols, rows) 1.476565 1.443449 2.128946 1.466841 1.470033 50.545873
3 rowCummins(X[cols, rows]) 2.469968 2.423796 2.444971 2.444297 2.462630 3.408119

Figure: Benchmarking of colCummins_X_S(), colCummins(X, rows, cols)() and colCummins(X[rows, cols])() on double+1000x100 data as well as rowCummins_X_S(), rowCummins(X, cols, rows)() and rowCummins(X[cols, rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+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 rowCummins_X_S 50.629 53.173 55.37933 54.36 55.378 77.377
1 colCummins_X_S 115.069 115.867 160.43144 118.73 125.288 3831.997
expr min lq mean median uq max
2 rowCummins_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.00000
1 colCummins_X_S 2.272788 2.179057 2.896955 2.184143 2.262415 49.52372

Figure: Benchmarking of colCummins_X_S() and rowCummins_X_S() on double+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 22.77 secs.

Reproducibility

To reproduce this report, do:

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

Copyright Dongcan Jiang. Last updated on 2019-09-10 20:37:49 (-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** ⚠️