Skip to content

colRowCounts_subset

Dongcan Jiang edited this page May 10, 2015 · 3 revisions

matrixStats: Benchmark report


colCounts() and rowCounts() benchmarks on subsetted computation

This report benchmark the performance of colCounts() and rowCounts() on subsetted computation.

Data type "logical"

Data

> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100, 
+     +100), naProb = 0) {
+     mode <- match.arg(mode)
+     n <- nrow * ncol
+     if (mode == "logical") {
+         X <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+     }     else if (mode == "index") {
+         X <- seq_len(n)
+         mode <- "integer"
+     }     else {
+         X <- runif(n, min = range[1], max = range[2])
+     }
+     storage.mode(X) <- mode
+     if (naProb > 0) 
+         X[sample(n, size = naProb * n)] <- NA
+     dim(X) <- c(nrow, ncol)
+     X
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+     set.seed(seed)
+     data <- list()
+     data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+     data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+     data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+     data[[4]] <- t(data[[3]])
+     data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+     data[[6]] <- t(data[[5]])
+     names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+     data
+ }
> data <- rmatrices(mode = mode)

Results

10x10 matrix

> X <- data[["10x10"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

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

expr min lq mean median uq max neval
colCounts_X_S 0.005384 0.0057790 0.0076935 0.0059465 0.0061550 0.170428 100
colCounts(X,rows,cols) 0.005801 0.0061375 0.0064140 0.0063020 0.0064855 0.008404 100
colCounts(X[rows,cols]) 0.007176 0.0074875 0.0077561 0.0076095 0.0077755 0.014095 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000 100
colCounts(X,rows,cols) 1.077452 1.062035 0.8336938 1.059783 1.053696 0.0493111 100
colCounts(X[rows,cols]) 1.332838 1.295639 1.0081302 1.279660 1.263282 0.0827035 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on logical+10x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr min lq mean median uq max neval
rowCounts_X_S 0.005357 0.0055655 0.0073684 0.0057185 0.0059035 0.163155 100
rowCounts(X,cols,rows) 0.005776 0.0059890 0.0062294 0.0061605 0.0063160 0.008153 100
rowCounts(X[cols,rows]) 0.006979 0.0072510 0.0075992 0.0074155 0.0075820 0.012321 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.0000000 1.000000 1.000000 1.0000000 100
rowCounts(X,cols,rows) 1.078215 1.076094 0.8454301 1.077293 1.069874 0.0499709 100
rowCounts(X[cols,rows]) 1.302781 1.302848 1.0313312 1.296756 1.284323 0.0755171 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on logical+10x10 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+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 neval
2 rowCounts_X_S 5.357 5.5655 7.36838 5.7185 5.9035 163.155 100
1 colCounts_X_S 5.384 5.7790 7.69352 5.9465 6.1550 170.428 100
expr min lq mean median uq max neval
2 rowCounts_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.000000 100
1 colCounts_X_S 1.00504 1.038361 1.044126 1.039871 1.042602 1.044577 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 matrix

> X <- data[["100x100"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

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

expr min lq mean median uq max neval
colCounts_X_S 0.018947 0.019930 0.0208104 0.0205495 0.0212630 0.029576 100
colCounts(X,rows,cols) 0.029228 0.030619 0.0312689 0.0309315 0.0311545 0.063351 100
colCounts(X[rows,cols]) 0.035158 0.036291 0.0372238 0.0369725 0.0375915 0.051626 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.542619 1.536327 1.502561 1.505219 1.465198 2.141973 100
colCounts(X[rows,cols]) 1.855597 1.820923 1.788711 1.799192 1.767930 1.745537 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on logical+100x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr min lq mean median uq max neval
rowCounts_X_S 0.023101 0.0236420 0.0240043 0.0238795 0.024174 0.027141 100
rowCounts(X,cols,rows) 0.027389 0.0280630 0.0289578 0.0286290 0.029635 0.035786 100
rowCounts(X[cols,rows]) 0.039200 0.0398555 0.0407704 0.0400935 0.040480 0.076089 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.185620 1.186998 1.206358 1.198894 1.225904 1.318522 100
rowCounts(X[cols,rows]) 1.696896 1.685792 1.698461 1.678992 1.674526 2.803471 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on logical+100x100 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+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 neval
colCounts_X_S 18.947 19.930 20.8104 20.5495 21.263 29.576 100
rowCounts_X_S 23.101 23.642 24.0043 23.8795 24.174 27.141 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts_X_S 1.219243 1.186252 1.153476 1.162048 1.136904 0.9176697 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 matrix

> X <- data[["1000x10"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

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

expr min lq mean median uq max neval
colCounts_X_S 0.018640 0.019780 0.0206665 0.0203625 0.021280 0.027603 100
colCounts(X,rows,cols) 0.030097 0.031035 0.0320233 0.0317420 0.032234 0.051039 100
colCounts(X[rows,cols]) 0.038484 0.039508 0.0407278 0.0400310 0.040821 0.078229 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.614646 1.569009 1.549524 1.558846 1.514756 1.849038 100
colCounts(X[rows,cols]) 2.064592 1.997371 1.970712 1.965918 1.918280 2.834076 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on logical+1000x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr min lq mean median uq max neval
rowCounts_X_S 0.027136 0.0280595 0.0291683 0.0284025 0.029076 0.059775 100
rowCounts(X,cols,rows) 0.033165 0.0347540 0.0360522 0.0355060 0.036862 0.054925 100
rowCounts(X[cols,rows]) 0.044851 0.0455980 0.0463997 0.0458900 0.047052 0.053661 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts(X,cols,rows) 1.222177 1.238582 1.236003 1.250101 1.267781 0.9188624 100
rowCounts(X[cols,rows]) 1.652823 1.625047 1.590756 1.615703 1.618242 0.8977164 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on logical+1000x10 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+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 neval
colCounts_X_S 18.640 19.7800 20.66652 20.3625 21.280 27.603 100
rowCounts_X_S 27.136 28.0595 29.16834 28.4025 29.076 59.775 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.455794 1.418579 1.411381 1.394843 1.366353 2.165526 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 matrix

> X <- data[["10x1000"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

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

expr min lq mean median uq max neval
colCounts_X_S 0.020857 0.022367 0.0231282 0.0228645 0.0234875 0.030590 100
colCounts(X,rows,cols) 0.033442 0.034594 0.0353813 0.0351415 0.0358185 0.042246 100
colCounts(X[rows,cols]) 0.037980 0.039530 0.0412870 0.0404555 0.0411230 0.082091 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.603395 1.546654 1.529791 1.536946 1.525003 1.381040 100
colCounts(X[rows,cols]) 1.820971 1.767336 1.785137 1.769359 1.750846 2.683589 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on logical+10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr min lq mean median uq max neval
rowCounts_X_S 0.023112 0.0235175 0.0238726 0.023717 0.0240180 0.029028 100
rowCounts(X,cols,rows) 0.027530 0.0286325 0.0294635 0.029170 0.0300180 0.035179 100
rowCounts(X[cols,rows]) 0.042246 0.0427420 0.0435779 0.042984 0.0433395 0.077803 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.191156 1.217498 1.234196 1.229920 1.249813 1.211899 100
rowCounts(X[cols,rows]) 1.827882 1.817455 1.825437 1.812371 1.804459 2.680274 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on logical+10x1000 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+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 neval
colCounts_X_S 20.857 22.3670 23.12817 22.8645 23.4875 30.590 100
rowCounts_X_S 23.112 23.5175 23.87260 23.7170 24.0180 29.028 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts_X_S 1.108117 1.051437 1.032187 1.037285 1.022587 0.9489376 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 matrix

> X <- data[["100x1000"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

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

expr min lq mean median uq max neval
colCounts_X_S 0.210573 0.2135550 0.2153174 0.2152890 0.2168370 0.223632 100
colCounts(X,rows,cols) 0.267100 0.2696795 0.2726299 0.2705985 0.2715000 0.364316 100
colCounts(X[rows,cols]) 0.386361 0.3890185 0.4089667 0.3903310 0.3918915 1.222766 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.268444 1.262811 1.266177 1.256908 1.252093 1.629087 100
colCounts(X[rows,cols]) 1.834808 1.821631 1.899366 1.813056 1.807309 5.467759 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on logical+100x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr min lq mean median uq max neval
rowCounts_X_S 0.212653 0.2143025 0.2183749 0.2154425 0.2170470 0.275730 100
rowCounts(X,cols,rows) 0.268597 0.2704125 0.2784853 0.2712515 0.2858325 0.327082 100
rowCounts(X[cols,rows]) 0.373669 0.3753110 0.3959550 0.3760725 0.3771535 1.189767 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.263076 1.261826 1.275262 1.259044 1.316915 1.186240 100
rowCounts(X[cols,rows]) 1.757177 1.751314 1.813189 1.745582 1.737658 4.314971 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on logical+100x1000 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+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 neval
colCounts_X_S 210.573 213.5550 215.3174 215.2890 216.837 223.632 100
rowCounts_X_S 212.653 214.3025 218.3749 215.4425 217.047 275.730 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.0000 1.0000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.009878 1.0035 1.0142 1.000713 1.000968 1.232963 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 matrix

> X <- data[["1000x100"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

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

expr min lq mean median uq max neval
colCounts_X_S 0.206296 0.2088270 0.2105008 0.2095975 0.211003 0.239486 100
colCounts(X,rows,cols) 0.257324 0.2595640 0.2612518 0.2607240 0.261561 0.295740 100
colCounts(X[rows,cols]) 0.368593 0.3708345 0.3903450 0.3718035 0.373097 1.183091 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.247353 1.242962 1.241096 1.243927 1.239608 1.234895 100
colCounts(X[rows,cols]) 1.786719 1.775798 1.854363 1.773893 1.768207 4.940126 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on logical+1000x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr min lq mean median uq max neval
rowCounts_X_S 0.217393 0.218990 0.2234541 0.2204600 0.2218095 0.261642 100
rowCounts(X,cols,rows) 0.277694 0.279795 0.2933039 0.2808940 0.3022375 0.377908 100
rowCounts(X[cols,rows]) 0.393659 0.395616 0.4231071 0.3972265 0.4071675 1.205718 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.277382 1.277661 1.312591 1.274127 1.362599 1.444371 100
rowCounts(X[cols,rows]) 1.810817 1.806548 1.893485 1.801808 1.835663 4.608274 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on logical+1000x100 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+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 neval
colCounts_X_S 206.296 208.827 210.5009 209.5975 211.0030 239.486 100
rowCounts_X_S 217.393 218.990 223.4541 220.4600 221.8095 261.642 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.053792 1.048667 1.061535 1.051826 1.051215 1.092515 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on logical+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Data type "integer"

Data

> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100, 
+     +100), naProb = 0) {
+     mode <- match.arg(mode)
+     n <- nrow * ncol
+     if (mode == "logical") {
+         X <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+     }     else if (mode == "index") {
+         X <- seq_len(n)
+         mode <- "integer"
+     }     else {
+         X <- runif(n, min = range[1], max = range[2])
+     }
+     storage.mode(X) <- mode
+     if (naProb > 0) 
+         X[sample(n, size = naProb * n)] <- NA
+     dim(X) <- c(nrow, ncol)
+     X
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+     set.seed(seed)
+     data <- list()
+     data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+     data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+     data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+     data[[4]] <- t(data[[3]])
+     data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+     data[[6]] <- t(data[[5]])
+     names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+     data
+ }
> data <- rmatrices(mode = mode)

Results

10x10 matrix

> X <- data[["10x10"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.005416 0.0057005 0.0061513 0.0059020 0.0060645 0.031272 100
colCounts(X,rows,cols) 0.005895 0.0061230 0.0062979 0.0062915 0.0063865 0.007867 100
colCounts(X[rows,cols]) 0.007269 0.0075050 0.0077130 0.0076530 0.0077785 0.011217 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
colCounts(X,rows,cols) 1.088442 1.074116 1.023841 1.065995 1.053096 0.2515669 100
colCounts(X[rows,cols]) 1.342134 1.316551 1.253885 1.296679 1.282628 0.3586915 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.005269 0.0055080 0.0059156 0.0056255 0.0057990 0.031555 100
rowCounts(X,cols,rows) 0.005696 0.0058985 0.0060822 0.0060715 0.0062050 0.007589 100
rowCounts(X[cols,rows]) 0.006934 0.0072965 0.0075060 0.0074625 0.0075995 0.012194 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts(X,cols,rows) 1.081040 1.070897 1.028170 1.079282 1.070012 0.2405007 100
rowCounts(X[cols,rows]) 1.315999 1.324709 1.268864 1.326549 1.310485 0.3864364 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on integer+10x10 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
2 rowCounts_X_S 5.269 5.5080 5.91555 5.6255 5.7990 31.555 100
1 colCounts_X_S 5.416 5.7005 6.15128 5.9020 6.0645 31.272 100
expr min lq mean median uq max neval
2 rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
1 colCounts_X_S 1.027899 1.034949 1.039849 1.049151 1.045784 0.9910315 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 matrix

> X <- data[["100x100"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.011864 0.0122845 0.0124659 0.012432 0.0126225 0.014931 100
colCounts(X,rows,cols) 0.013964 0.0144515 0.0149858 0.014630 0.0147830 0.045248 100
colCounts(X[rows,cols]) 0.028060 0.0284150 0.0288360 0.028585 0.0287925 0.037297 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.177006 1.176401 1.202144 1.176802 1.171163 3.030473 100
colCounts(X[rows,cols]) 2.365138 2.313077 2.313191 2.299308 2.281046 2.497957 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.014489 0.0147995 0.0149601 0.0149240 0.0150840 0.016553 100
rowCounts(X,cols,rows) 0.015342 0.0157365 0.0161278 0.0158935 0.0160595 0.023975 100
rowCounts(X[cols,rows]) 0.030468 0.0309350 0.0314921 0.0311505 0.0313750 0.065294 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.058872 1.063313 1.078056 1.064963 1.064671 1.448378 100
rowCounts(X[cols,rows]) 2.102837 2.090273 2.105067 2.087276 2.080019 3.944542 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on integer+100x100 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 11.864 12.2845 12.46590 12.432 12.6225 14.931 100
rowCounts_X_S 14.489 14.7995 14.96013 14.924 15.0840 16.553 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.00000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.221258 1.20473 1.200084 1.200451 1.195009 1.108633 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 matrix

> X <- data[["1000x10"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.012617 0.0129420 0.0131594 0.013114 0.0133165 0.014948 100
colCounts(X,rows,cols) 0.015865 0.0162025 0.0164124 0.016323 0.0164750 0.021599 100
colCounts(X[rows,cols]) 0.034351 0.0348265 0.0354155 0.035082 0.0352675 0.066581 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.257430 1.251932 1.247203 1.244700 1.237187 1.444943 100
colCounts(X[rows,cols]) 2.722596 2.690967 2.691273 2.675156 2.648406 4.454174 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.015106 0.015394 0.0158660 0.0155255 0.015647 0.041759 100
rowCounts(X,cols,rows) 0.016699 0.016973 0.0174394 0.0170915 0.017284 0.032095 100
rowCounts(X[cols,rows]) 0.032107 0.032626 0.0331494 0.0328140 0.033003 0.042608 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts(X,cols,rows) 1.105455 1.102572 1.099165 1.100866 1.104621 0.7685768 100
rowCounts(X[cols,rows]) 2.125447 2.119397 2.089327 2.113555 2.109222 1.0203309 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on integer+1000x10 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 12.617 12.942 13.15938 13.1140 13.3165 14.948 100
rowCounts_X_S 15.106 15.394 15.86605 15.5255 15.6470 41.759 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.197274 1.189461 1.205684 1.183887 1.175008 2.793618 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 matrix

> X <- data[["10x1000"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.012544 0.0128755 0.0130978 0.013028 0.0132255 0.016785 100
colCounts(X,rows,cols) 0.016023 0.0163535 0.0165430 0.016547 0.0167005 0.018115 100
colCounts(X[rows,cols]) 0.029667 0.0301705 0.0309225 0.030377 0.0306820 0.065074 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.00000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.277344 1.270125 1.263028 1.27011 1.262750 1.079237 100
colCounts(X[rows,cols]) 2.365035 2.343249 2.360886 2.33167 2.319912 3.876914 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.014244 0.0146340 0.0149823 0.0147930 0.0149585 0.022779 100
rowCounts(X,cols,rows) 0.015847 0.0161915 0.0163528 0.0163275 0.0164940 0.018114 100
rowCounts(X[cols,rows]) 0.033581 0.0339280 0.0346973 0.0340915 0.0343495 0.067027 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts(X,cols,rows) 1.112539 1.106430 1.091470 1.103732 1.102651 0.7952061 100
rowCounts(X[cols,rows]) 2.357554 2.318436 2.315878 2.304570 2.296320 2.9424909 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on integer+10x1000 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 12.544 12.8755 13.09785 13.028 13.2255 16.785 100
rowCounts_X_S 14.244 14.6340 14.98234 14.793 14.9585 22.779 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.135523 1.136577 1.143878 1.135477 1.131035 1.357105 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 matrix

> X <- data[["100x1000"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.068132 0.0685380 0.0691408 0.0687405 0.0689565 0.086163 100
colCounts(X,rows,cols) 0.088553 0.0890335 0.0906975 0.0892770 0.0895445 0.181805 100
colCounts(X[rows,cols]) 0.243007 0.2442635 0.2623006 0.2447515 0.2453595 1.067442 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.299727 1.299038 1.311779 1.298754 1.298565 2.110012 100
colCounts(X[rows,cols]) 3.566709 3.563913 3.793715 3.560514 3.558178 12.388635 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.091334 0.0918785 0.0932175 0.0921075 0.0924055 0.117729 100
rowCounts(X,cols,rows) 0.094401 0.0948775 0.0968161 0.0950850 0.0955015 0.127119 100
rowCounts(X[cols,rows]) 0.251592 0.2528315 0.2755978 0.2533825 0.2556230 1.137349 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.033580 1.032641 1.038604 1.032326 1.033505 1.079759 100
rowCounts(X[cols,rows]) 2.754637 2.751803 2.956502 2.750943 2.766318 9.660738 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on integer+100x1000 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 68.132 68.5380 69.14082 68.7405 68.9565 86.163 100
rowCounts_X_S 91.334 91.8785 93.21751 92.1075 92.4055 117.729 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.340545 1.340548 1.348227 1.339931 1.340055 1.366352 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 matrix

> X <- data[["1000x100"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.063982 0.0644120 0.0652741 0.0646515 0.0648415 0.091861 100
colCounts(X,rows,cols) 0.081098 0.0814875 0.0825432 0.0816145 0.0818045 0.116981 100
colCounts(X[rows,cols]) 0.225304 0.2266645 0.2437216 0.2272195 0.2277855 1.050614 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.267513 1.265098 1.264563 1.262376 1.261607 1.273457 100
colCounts(X[rows,cols]) 3.521365 3.518979 3.733819 3.514528 3.512958 11.436997 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.095760 0.0962295 0.0969354 0.0964120 0.0966525 0.126040 100
rowCounts(X,cols,rows) 0.101907 0.1023455 0.1038735 0.1025330 0.1029950 0.209546 100
rowCounts(X[cols,rows]) 0.272514 0.2738145 0.2913992 0.2744165 0.2751320 1.088787 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.064192 1.063556 1.071574 1.063488 1.065622 1.662536 100
rowCounts(X[cols,rows]) 2.845802 2.845432 3.006118 2.846290 2.846610 8.638424 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on integer+1000x100 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 63.982 64.4120 65.27407 64.6515 64.8415 91.861 100
rowCounts_X_S 95.760 96.2295 96.93537 96.4120 96.6525 126.040 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.496671 1.493969 1.485052 1.491257 1.490596 1.372073 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_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), naProb = 0) {
+     mode <- match.arg(mode)
+     n <- nrow * ncol
+     if (mode == "logical") {
+         X <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+     }     else if (mode == "index") {
+         X <- seq_len(n)
+         mode <- "integer"
+     }     else {
+         X <- runif(n, min = range[1], max = range[2])
+     }
+     storage.mode(X) <- mode
+     if (naProb > 0) 
+         X[sample(n, size = naProb * n)] <- NA
+     dim(X) <- c(nrow, ncol)
+     X
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+     set.seed(seed)
+     data <- list()
+     data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+     data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+     data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+     data[[4]] <- t(data[[3]])
+     data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+     data[[6]] <- t(data[[5]])
+     names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+     data
+ }
> data <- rmatrices(mode = mode)

Results

10x10 matrix

> X <- data[["10x10"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.005776 0.0060265 0.0065510 0.0062320 0.0063900 0.034787 100
colCounts(X,rows,cols) 0.006246 0.0064510 0.0067978 0.0066205 0.0067825 0.015304 100
colCounts(X[rows,cols]) 0.007646 0.0079705 0.0082681 0.0081205 0.0083660 0.012421 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
colCounts(X,rows,cols) 1.081371 1.070439 1.037670 1.062339 1.061424 0.4399345 100
colCounts(X[rows,cols]) 1.323754 1.322575 1.262102 1.303033 1.309233 0.3570587 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.005661 0.0059185 0.0063226 0.0060510 0.0062015 0.030947 100
rowCounts(X,cols,rows) 0.006097 0.0063860 0.0066006 0.0065365 0.0066595 0.009885 100
rowCounts(X[cols,rows]) 0.007422 0.0077140 0.0079681 0.0079370 0.0080815 0.012554 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts(X,cols,rows) 1.077018 1.078990 1.043979 1.080235 1.073853 0.3194171 100
rowCounts(X[cols,rows]) 1.311076 1.303371 1.260251 1.311684 1.303152 0.4056613 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on double+10x10 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
2 rowCounts_X_S 5.661 5.9185 6.32259 6.051 6.2015 30.947 100
1 colCounts_X_S 5.776 6.0265 6.55103 6.232 6.3900 34.787 100
expr min lq mean median uq max neval
2 rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
1 colCounts_X_S 1.020314 1.018248 1.036131 1.029912 1.030396 1.124083 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 matrix

> X <- data[["100x100"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.022840 0.023279 0.0234452 0.0233915 0.023573 0.025221 100
colCounts(X,rows,cols) 0.024030 0.024287 0.0248283 0.0244435 0.024567 0.059807 100
colCounts(X[rows,cols]) 0.040091 0.040496 0.0407492 0.0406490 0.040848 0.044909 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.052102 1.043301 1.058993 1.044974 1.042167 2.371318 100
colCounts(X[rows,cols]) 1.755298 1.739594 1.738062 1.737768 1.732830 1.780619 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.028664 0.0289325 0.0290869 0.0290480 0.029165 0.031082 100
rowCounts(X,cols,rows) 0.029365 0.0297075 0.0300238 0.0298345 0.030020 0.035005 100
rowCounts(X[cols,rows]) 0.046469 0.0468455 0.0475393 0.0471835 0.047487 0.083667 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.024456 1.026787 1.032210 1.027076 1.029316 1.126214 100
rowCounts(X[cols,rows]) 1.621162 1.619131 1.634387 1.624329 1.628219 2.691815 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on double+100x100 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 22.840 23.2790 23.44519 23.3915 23.573 25.221 100
rowCounts_X_S 28.664 28.9325 29.08693 29.0480 29.165 31.082 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.254991 1.242858 1.240635 1.241819 1.237221 1.232386 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 matrix

> X <- data[["1000x10"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.022194 0.0225290 0.0233550 0.0226715 0.0229025 0.054181 100
colCounts(X,rows,cols) 0.023808 0.0241005 0.0250075 0.0242805 0.0245185 0.054084 100
colCounts(X[rows,cols]) 0.042277 0.0429260 0.0445920 0.0431880 0.0435835 0.080696 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
colCounts(X,rows,cols) 1.072722 1.069754 1.070753 1.070970 1.070560 0.9982097 100
colCounts(X[rows,cols]) 1.904884 1.905366 1.909308 1.904947 1.903002 1.4893782 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.029197 0.0297760 0.0318996 0.0303520 0.0314330 0.062679 100
rowCounts(X,cols,rows) 0.031702 0.0322705 0.0341869 0.0331555 0.0340710 0.054385 100
rowCounts(X[cols,rows]) 0.050092 0.0514180 0.0548176 0.0529750 0.0543675 0.082837 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.085797 1.083776 1.071700 1.092366 1.083924 0.867675 100
rowCounts(X[cols,rows]) 1.715656 1.726827 1.718441 1.745354 1.729631 1.321607 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on double+1000x10 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 22.194 22.529 23.35505 22.6715 22.9025 54.181 100
rowCounts_X_S 29.197 29.776 31.89964 30.3520 31.4330 62.679 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.00000 1.000000 100
rowCounts_X_S 1.315536 1.321674 1.365856 1.338773 1.37247 1.156845 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 matrix

> X <- data[["10x1000"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.023795 0.0241870 0.0244465 0.0244075 0.024690 0.027255 100
colCounts(X,rows,cols) 0.027009 0.0273575 0.0278870 0.0275005 0.027737 0.047748 100
colCounts(X[rows,cols]) 0.043498 0.0444555 0.0455218 0.0447985 0.045130 0.082122 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.135070 1.131083 1.140735 1.126723 1.123410 1.751899 100
colCounts(X[rows,cols]) 1.828031 1.837992 1.862096 1.835440 1.827865 3.013098 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.026702 0.027090 0.0274589 0.0272360 0.0274380 0.037999 100
rowCounts(X,cols,rows) 0.028191 0.028617 0.0289895 0.0287405 0.0289060 0.042267 100
rowCounts(X[cols,rows]) 0.046817 0.047344 0.0482336 0.0475515 0.0478495 0.085224 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.055764 1.056368 1.055740 1.055239 1.053502 1.112319 100
rowCounts(X[cols,rows]) 1.753314 1.747656 1.756576 1.745906 1.743914 2.242796 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on double+10x1000 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 23.795 24.187 24.44652 24.4075 24.690 27.255 100
rowCounts_X_S 26.702 27.090 27.45889 27.2360 27.438 37.999 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.0000 1.000000 100
rowCounts_X_S 1.122168 1.120023 1.123223 1.115887 1.1113 1.394203 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 matrix

> X <- data[["100x1000"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.176507 0.1770745 0.1824289 0.1774740 0.1821225 0.229395 100
colCounts(X,rows,cols) 0.183405 0.1839240 0.1926547 0.1843275 0.1914855 0.344075 100
colCounts(X[rows,cols]) 0.362784 0.3646015 0.4347960 0.3666355 0.3951210 1.290293 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.039081 1.038682 1.056054 1.038617 1.051411 1.499924 100
colCounts(X[rows,cols]) 2.055352 2.059029 2.383373 2.065855 2.169534 5.624765 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.213232 0.2137795 0.2172787 0.214029 0.2143360 0.296912 100
rowCounts(X,cols,rows) 0.215175 0.2158875 0.2187254 0.216126 0.2163690 0.283987 100
rowCounts(X[cols,rows]) 0.391095 0.3973470 0.4712330 0.399968 0.4033565 1.213951 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.0000000 100
rowCounts(X,cols,rows) 1.009112 1.009861 1.006658 1.009798 1.009485 0.9564686 100
rowCounts(X[cols,rows]) 1.834129 1.858677 2.168795 1.868756 1.881889 4.0885885 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on double+100x1000 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 176.507 177.0745 182.4289 177.474 182.1225 229.395 100
rowCounts_X_S 213.232 213.7795 217.2787 214.029 214.3360 296.912 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.208065 1.207286 1.191032 1.205974 1.176878 1.294326 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 matrix

> X <- data[["1000x100"]]
> rows <- sample.int(dim(X)[1], size = dim(X)[1] * 0.7)
> cols <- sample.int(dim(X)[2], size = dim(X)[2] * 0.7)
> X_S <- X[rows, cols]
> value <- 42
> colStats <- microbenchmark(colCounts_X_S = colCounts(X_S, value = value, na.rm = FALSE), `colCounts(X,rows,cols)` = colCounts(X, 
+     value = value, na.rm = FALSE, rows = rows, cols = cols), `colCounts(X[rows,cols])` = colCounts(X[rows, 
+     cols], value = value, na.rm = FALSE), unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> rowStats <- microbenchmark(rowCounts_X_S = rowCounts(X_S, value = value, na.rm = FALSE), `rowCounts(X,cols,rows)` = rowCounts(X, 
+     value = value, na.rm = FALSE, rows = cols, cols = rows), `rowCounts(X[cols,rows])` = rowCounts(X[cols, 
+     rows], value = value, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(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 neval
colCounts_X_S 0.172232 0.1727555 0.1761024 0.1730220 0.1775325 0.204671 100
colCounts(X,rows,cols) 0.176541 0.1769315 0.1809258 0.1772205 0.1819450 0.255468 100
colCounts(X[rows,cols]) 0.356451 0.3595605 0.4228386 0.3610030 0.3692855 1.199084 100
expr min lq mean median uq max neval
colCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
colCounts(X,rows,cols) 1.025019 1.024173 1.027390 1.024266 1.024855 1.248189 100
colCounts(X[rows,cols]) 2.069598 2.081326 2.401095 2.086457 2.080101 5.858593 100
Table: Benchmarking of rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(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 neval
rowCounts_X_S 0.217591 0.2181705 0.2216322 0.2183865 0.2192595 0.269604 100
rowCounts(X,cols,rows) 0.219859 0.2203595 0.2254859 0.2207110 0.2236775 0.410901 100
rowCounts(X[cols,rows]) 0.402089 0.4058085 0.8574803 0.4078440 0.4189660 39.273514 100
expr min lq mean median uq max neval
rowCounts_X_S 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts(X,cols,rows) 1.010423 1.010033 1.017388 1.010644 1.020150 1.524091 100
rowCounts(X[cols,rows]) 1.847912 1.860052 3.868934 1.867533 1.910823 145.671110 100
Figure: Benchmarking of colCounts_X_S(), colCounts(X,rows,cols)() and colCounts(X[rows,cols])() on double+1000x100 data as well as rowCounts_X_S(), rowCounts(X,cols,rows)() and rowCounts(X[cols,rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colCounts_X_S() and rowCounts_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 neval
colCounts_X_S 172.232 172.7555 176.1024 173.0220 177.5325 204.671 100
rowCounts_X_S 217.591 218.1705 221.6322 218.3865 219.2595 269.604 100
expr min lq mean median uq max neval
colCounts_X_S 1.00000 1.000000 1.000000 1.000000 1.000000 1.000000 100
rowCounts_X_S 1.26336 1.262886 1.258542 1.262189 1.235039 1.317255 100
Figure: Benchmarking of colCounts_X_S() and rowCounts_X_S() on double+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Appendix

Session information

R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

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-2 matrixStats_0.14.0   ggplot2_1.0.1       
[4] knitr_1.10.5         R.devices_2.13.0     R.utils_2.0.2       
[7] R.oo_1.19.0          R.methodsS3_1.7.0   

loaded via a namespace (and not attached):
 [1] base64enc_0.1-2    colorspace_1.2-6   dichromat_2.0-0    digest_0.6.8      
 [5] grid_3.0.2         gtable_0.1.2       highr_0.5          labeling_0.3      
 [9] magrittr_1.5       MASS_7.3-29        munsell_0.4.2      plyr_1.8          
[13] proto_0.3-10       R.cache_0.10.0     RColorBrewer_1.1-2 reshape2_1.2.2    
[17] R.rsp_0.20.0       scales_0.2.3       stringi_0.4-1      stringr_1.0.0     
[21] tools_3.0.2       

Total processing time was 14.81 secs.

Reproducibility

To reproduce this report, do:

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

Copyright Dongcan Jiang. Last updated on 2015-05-09 07:47:48 (+0000 UTC). Powered by RSP.

<script> var link = document.createElement('link'); link.rel = 'icon'; link.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABHVBMVEUAAAAAAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8BAf4CAv0DA/wdHeIeHuEgIN8kJNslJdomJtkoKNc+PsE/P8BAQL9BQb5tbZJvb5BwcI9yco1zc4yVlWqWlmmYmGeZmWaammXm5hnn5xjo6Bfq6hX29gn39wj4+Af//wDuRpPZAAAAX3RSTlMAAQIDCAoLDA0ODyMkJSYnPT4/QEFdX2JjZmdoamtsbnBxcqiqrq+xsrO0tbq8vcvMzc7h4uXn6Ovs+Pn6+////////////////////////////////////////////yKADR0AAAEeSURBVDiNvZNXV8JAEIUXCAEVK/aOXQQ7okQvSFPECvbg/v+f4eScELITiE94n7Jzv5xJZu4K8c/SYuNjQ1ovd3AtbYBkpBMDXezQ6gUcna8EuR9NWkahUqtV8tbTdoT5x1QsNT8l6aNRpMOhQgR3qPTSkrbMJzpuurssUuFVutSgwlzH18/ofanoEciEHWAJKP+ogFkCFhxgH3iXTE0g1fYjV7j+5sBXAZftHqPALfelrALDNhAH6l7gDpiwgUng3gvUgbhvixtgxAbCxh8fKVLAm99vWpMut1TfLLoHpWeBZxV4UEYtlrsta961zdCud91bSqiiRzwwByxS+oYauXVdMAWmTzuhPZkKcJ+kze7lLDeXnOl5NfwvTr/0C8BllPKPvS4yAAAAAElFTkSuQmCC" document.getElementsByTagName('head')[0].appendChild(link); </script>

[Benchmark reports](Benchmark reports)

Clone this wiki locally