-
Notifications
You must be signed in to change notification settings - Fork 0
colRowCounts
matrixStats: Benchmark report
This report benchmark the performance of colCounts() and rowCounts() against alternative methods.
- colSums() and rowSums()
- apply() + sum()
> 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)> X <- data[["10x10"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.005938 | 0.0067165 | 0.0080754 | 0.0082460 | 0.0088910 | 0.025245 | 100 |
| colSums | 0.008057 | 0.0088875 | 0.0099427 | 0.0099305 | 0.0104160 | 0.020142 | 100 |
| apply+sum | 0.059256 | 0.0607415 | 0.0627614 | 0.0616695 | 0.0626665 | 0.118169 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 1.356854 | 1.323234 | 1.231234 | 1.204281 | 1.171522 | 0.797861 | 100 |
| apply+sum | 9.979117 | 9.043624 | 7.771964 | 7.478717 | 7.048307 | 4.680887 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.006094 | 0.0067220 | 0.0081886 | 0.0074820 | 0.0089930 | 0.026223 | 100 |
| rowSums | 0.007512 | 0.0083075 | 0.0094609 | 0.0097285 | 0.0103050 | 0.016426 | 100 |
| apply+sum | 0.059751 | 0.0616895 | 0.0633502 | 0.0623910 | 0.0633815 | 0.118581 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 100 |
| rowSums | 1.232688 | 1.235867 | 1.155373 | 1.300254 | 1.145891 | 0.6263967 | 100 |
| apply+sum | 9.804890 | 9.177254 | 7.736375 | 8.338813 | 7.047871 | 4.5220227 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on logical+10x10 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 6.094 | 6.7220 | 8.18861 | 7.482 | 8.993 | 26.223 | 100 |
| 1 | colCounts | 5.938 | 6.7165 | 8.07536 | 8.246 | 8.891 | 25.245 | 100 |
| expr | min | lq | mean | median | uq | max | neval | |
|---|---|---|---|---|---|---|---|---|
| 2 | rowCounts | 1.0000000 | 1.0000000 | 1.0000000 | 1.000000 | 1.0000000 | 1.0000000 | 100 |
| 1 | colCounts | 0.9744011 | 0.9991818 | 0.9861698 | 1.102112 | 0.9886578 | 0.9627045 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on logical+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x100"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.036579 | 0.0395410 | 0.0432680 | 0.0434065 | 0.0451985 | 0.070758 | 100 |
| colSums | 0.088357 | 0.0906760 | 0.1266016 | 0.0920435 | 0.0936095 | 1.763543 | 100 |
| apply+sum | 0.497600 | 0.5070345 | 0.5219988 | 0.5176640 | 0.5271675 | 0.702221 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.415512 | 2.293215 | 2.925988 | 2.12050 | 2.071075 | 24.923585 | 100 |
| apply+sum | 13.603434 | 12.823006 | 12.064315 | 11.92596 | 11.663385 | 9.924263 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.041875 | 0.0452355 | 0.0484104 | 0.0475000 | 0.0500030 | 0.076317 | 100 |
| rowSums | 0.104313 | 0.1055440 | 0.1071632 | 0.1063995 | 0.1072025 | 0.126581 | 100 |
| apply+sum | 0.497969 | 0.5036205 | 0.5462540 | 0.5080855 | 0.5176900 | 2.208795 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.491057 | 2.333212 | 2.213638 | 2.23999 | 2.143921 | 1.658621 | 100 |
| apply+sum | 11.891797 | 11.133302 | 11.283803 | 10.69654 | 10.353179 | 28.942372 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on logical+100x100 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 36.579 | 39.5410 | 43.26800 | 43.4065 | 45.1985 | 70.758 | 100 |
| rowCounts | 41.875 | 45.2355 | 48.41045 | 47.5000 | 50.0030 | 76.317 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.144783 | 1.144015 | 1.118851 | 1.094306 | 1.106298 | 1.078564 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on logical+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x10"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.035913 | 0.038243 | 0.0408713 | 0.0402695 | 0.0428585 | 0.061141 | 100 |
| colSums | 0.087694 | 0.088412 | 0.0901938 | 0.0891375 | 0.0898490 | 0.111044 | 100 |
| apply+sum | 0.222391 | 0.224935 | 0.2481667 | 0.2266585 | 0.2281415 | 1.254100 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.441846 | 2.311848 | 2.206775 | 2.213524 | 2.096410 | 1.816195 | 100 |
| apply+sum | 6.192493 | 5.881730 | 6.071908 | 5.628540 | 5.323133 | 20.511604 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.042930 | 0.0471360 | 0.0497080 | 0.0487460 | 0.052275 | 0.079379 | 100 |
| rowSums | 0.105768 | 0.1067035 | 0.1089648 | 0.1075655 | 0.108248 | 0.138420 | 100 |
| apply+sum | 0.222589 | 0.2263275 | 0.2503524 | 0.2281120 | 0.230878 | 1.232702 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.463732 | 2.263737 | 2.192101 | 2.206653 | 2.070741 | 1.743786 | 100 |
| apply+sum | 5.184929 | 4.801585 | 5.036466 | 4.679604 | 4.416605 | 15.529321 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on logical+1000x10 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 35.913 | 38.243 | 40.87129 | 40.2695 | 42.8585 | 61.141 | 100 |
| rowCounts | 42.930 | 47.136 | 49.70795 | 48.7460 | 52.2750 | 79.379 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.195389 | 1.232539 | 1.216207 | 1.210494 | 1.219711 | 1.298294 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on logical+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["10x1000"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.039266 | 0.0425685 | 0.0499366 | 0.0475745 | 0.0562715 | 0.071372 | 100 |
| colSums | 0.089403 | 0.0914930 | 0.0947872 | 0.0934355 | 0.0973960 | 0.116637 | 100 |
| apply+sum | 3.119022 | 3.1601980 | 3.3255419 | 3.2152245 | 3.3158165 | 5.537935 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.276855 | 2.149312 | 1.898151 | 1.963983 | 1.730823 | 1.634212 | 100 |
| apply+sum | 79.433148 | 74.237946 | 66.595294 | 67.582938 | 58.925326 | 77.592543 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.042912 | 0.0465335 | 0.0526830 | 0.0518285 | 0.0582990 | 0.073202 | 100 |
| rowSums | 0.105237 | 0.1068495 | 0.1102865 | 0.1080705 | 0.1120115 | 0.128831 | 100 |
| apply+sum | 3.091413 | 3.1668350 | 3.3342174 | 3.2436465 | 3.3429070 | 4.604021 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.452391 | 2.296184 | 2.093398 | 2.085156 | 1.921328 | 1.759938 | 100 |
| apply+sum | 72.040758 | 68.054950 | 63.288285 | 62.584225 | 57.340726 | 62.894743 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on logical+10x1000 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 39.266 | 42.5685 | 49.93659 | 47.5745 | 56.2715 | 71.372 | 100 |
| rowCounts | 42.912 | 46.5335 | 52.68301 | 51.8285 | 58.2990 | 73.202 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 100 |
| rowCounts | 1.092854 | 1.093144 | 1.054998 | 1.089418 | 1.036031 | 1.02564 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on logical+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x1000"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.355991 | 0.3622200 | 0.3782094 | 0.3772685 | 0.3867415 | 0.453541 | 100 |
| colSums | 0.800710 | 0.8074205 | 1.4562706 | 0.8257325 | 0.8781550 | 43.417423 | 100 |
| apply+sum | 4.697739 | 4.7985110 | 5.3041886 | 4.8985055 | 6.0378795 | 7.193121 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 100 |
| colSums | 2.249242 | 2.229089 | 3.850435 | 2.188713 | 2.270651 | 95.72987 | 100 |
| apply+sum | 13.196230 | 13.247504 | 14.024477 | 12.984136 | 15.612184 | 15.85991 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.408146 | 0.4142640 | 0.4340272 | 0.4300310 | 0.4379550 | 0.625429 | 100 |
| rowSums | 0.961649 | 0.9693825 | 1.1144560 | 0.9791385 | 0.9937745 | 2.859870 | 100 |
| apply+sum | 4.747159 | 4.8462455 | 5.8856342 | 4.9676860 | 6.3587870 | 47.848796 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.00000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.35614 | 2.340011 | 2.56771 | 2.276902 | 2.269125 | 4.572653 | 100 |
| apply+sum | 11.63103 | 11.698447 | 13.56052 | 11.551925 | 14.519270 | 76.505560 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on logical+100x1000 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 355.991 | 362.220 | 378.2094 | 377.2685 | 386.7415 | 453.541 | 100 |
| rowCounts | 408.146 | 414.264 | 434.0272 | 430.0310 | 437.9550 | 625.429 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.146507 | 1.143681 | 1.147585 | 1.139854 | 1.132423 | 1.378991 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on logical+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x100"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.350349 | 0.3558935 | 0.3673879 | 0.3658435 | 0.3735365 | 0.480174 | 100 |
| colSums | 0.794660 | 0.7980335 | 0.9464144 | 0.8052210 | 0.8212955 | 1.832601 | 100 |
| apply+sum | 1.962195 | 1.9924685 | 2.2194187 | 2.0185175 | 2.1264470 | 3.155022 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.268195 | 2.242338 | 2.576063 | 2.200998 | 2.198702 | 3.816535 | 100 |
| apply+sum | 5.600687 | 5.598497 | 6.041077 | 5.517434 | 5.692742 | 6.570581 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.414670 | 0.419928 | 0.432341 | 0.428901 | 0.437181 | 0.489343 | 100 |
| rowSums | 0.967677 | 0.971479 | 1.522248 | 0.975393 | 1.001624 | 42.870240 | 100 |
| apply+sum | 1.983647 | 2.016538 | 2.281843 | 2.044653 | 2.720711 | 3.200574 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.333607 | 2.313442 | 3.520943 | 2.274168 | 2.291098 | 87.607752 | 100 |
| apply+sum | 4.783676 | 4.802104 | 5.277877 | 4.767191 | 6.223305 | 6.540553 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on logical+1000x100 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 350.349 | 355.8935 | 367.3879 | 365.8435 | 373.5365 | 480.174 | 100 |
| rowCounts | 414.670 | 419.9280 | 432.3410 | 428.9010 | 437.1810 | 489.343 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.183591 | 1.179926 | 1.176797 | 1.172362 | 1.170384 | 1.019095 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on logical+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> 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)> X <- data[["10x10"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.005682 | 0.0064400 | 0.0077954 | 0.0076020 | 0.0087730 | 0.023538 | 100 |
| colSums | 0.007743 | 0.0088525 | 0.0097964 | 0.0098845 | 0.0103940 | 0.019366 | 100 |
| apply+sum | 0.059633 | 0.0611430 | 0.0631214 | 0.0618195 | 0.0628015 | 0.115958 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 100 |
| colSums | 1.362724 | 1.374612 | 1.256690 | 1.300250 | 1.184772 | 0.8227547 | 100 |
| apply+sum | 10.495072 | 9.494255 | 8.097273 | 8.132005 | 7.158498 | 4.9264169 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.005950 | 0.0066280 | 0.0078493 | 0.0076265 | 0.0087445 | 0.024736 | 100 |
| rowSums | 0.007211 | 0.0082150 | 0.0094199 | 0.0094705 | 0.0100245 | 0.018920 | 100 |
| apply+sum | 0.058600 | 0.0607045 | 0.0626365 | 0.0614350 | 0.0626330 | 0.119455 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 100 |
| rowSums | 1.211933 | 1.239439 | 1.200097 | 1.241788 | 1.146378 | 0.7648771 | 100 |
| apply+sum | 9.848740 | 9.158796 | 7.979906 | 8.055464 | 7.162559 | 4.8291963 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on integer+10x10 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 |
|---|---|---|---|---|---|---|---|
| colCounts | 5.682 | 6.440 | 7.79539 | 7.6020 | 8.7730 | 23.538 | 100 |
| rowCounts | 5.950 | 6.628 | 7.84928 | 7.6265 | 8.7445 | 24.736 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 100 |
| rowCounts | 1.047166 | 1.029192 | 1.006913 | 1.003223 | 0.9967514 | 1.050896 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x100"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.015487 | 0.0162980 | 0.0186450 | 0.0186025 | 0.0194460 | 0.043599 | 100 |
| colSums | 0.088638 | 0.0895070 | 0.1236637 | 0.0902290 | 0.0908410 | 1.746604 | 100 |
| apply+sum | 0.499101 | 0.5017345 | 0.5106780 | 0.5053695 | 0.5121805 | 0.577766 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.00000 | 100 |
| colSums | 5.723381 | 5.491901 | 6.632552 | 4.85037 | 4.671449 | 40.06064 | 100 |
| apply+sum | 32.227094 | 30.785035 | 27.389602 | 27.16675 | 26.338604 | 13.25182 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.018273 | 0.0189520 | 0.0210456 | 0.0206605 | 0.0220100 | 0.036831 | 100 |
| rowSums | 0.104563 | 0.1054375 | 0.1079447 | 0.1061655 | 0.1068625 | 0.139020 | 100 |
| apply+sum | 0.495515 | 0.5023850 | 0.5441405 | 0.5059065 | 0.5161050 | 2.212074 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 100 |
| rowSums | 5.722268 | 5.563397 | 5.129077 | 5.138574 | 4.85518 | 3.774538 | 100 |
| apply+sum | 27.117332 | 26.508284 | 25.855274 | 24.486653 | 23.44866 | 60.060112 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on integer+100x100 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 15.487 | 16.298 | 18.64496 | 18.6025 | 19.446 | 43.599 | 100 |
| rowCounts | 18.273 | 18.952 | 21.04563 | 20.6605 | 22.010 | 36.831 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.0000000 | 100 |
| rowCounts | 1.179893 | 1.162842 | 1.128757 | 1.11063 | 1.131852 | 0.8447671 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x10"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.014599 | 0.015304 | 0.0170788 | 0.0173265 | 0.0180870 | 0.033042 | 100 |
| colSums | 0.087615 | 0.088299 | 0.0895675 | 0.0889625 | 0.0894515 | 0.109900 | 100 |
| apply+sum | 0.222761 | 0.225360 | 0.2479239 | 0.2265370 | 0.2278000 | 1.236478 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 100 |
| colSums | 6.001438 | 5.769668 | 5.244363 | 5.134476 | 4.945624 | 3.32607 | 100 |
| apply+sum | 15.258648 | 14.725562 | 14.516464 | 13.074597 | 12.594681 | 37.42140 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.018388 | 0.019063 | 0.0210177 | 0.0213135 | 0.0218810 | 0.046230 | 100 |
| rowSums | 0.105702 | 0.106704 | 0.1078388 | 0.1072280 | 0.1077245 | 0.137149 | 100 |
| apply+sum | 0.223146 | 0.225356 | 0.2480699 | 0.2264370 | 0.2287040 | 1.223689 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.00000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 100 |
| rowSums | 5.748423 | 5.59744 | 5.130844 | 5.03099 | 4.923198 | 2.966667 | 100 |
| apply+sum | 12.135414 | 11.82164 | 11.802880 | 10.62411 | 10.452173 | 26.469587 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on integer+1000x10 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 14.599 | 15.304 | 17.07881 | 17.3265 | 18.087 | 33.042 | 100 |
| rowCounts | 18.388 | 19.063 | 21.01774 | 21.3135 | 21.881 | 46.230 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.259538 | 1.245622 | 1.230633 | 1.23011 | 1.209764 | 1.399128 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["10x1000"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.016090 | 0.017190 | 0.022674 | 0.020080 | 0.0261005 | 0.040684 | 100 |
| colSums | 0.089775 | 0.091518 | 0.095203 | 0.093436 | 0.0988845 | 0.120075 | 100 |
| apply+sum | 3.083524 | 3.161154 | 3.295713 | 3.209097 | 3.2908455 | 4.094655 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 5.579553 | 5.323909 | 4.198774 | 4.653187 | 3.788606 | 2.951406 | 100 |
| apply+sum | 191.642262 | 183.894968 | 145.352073 | 159.815612 | 126.083619 | 100.645340 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.017991 | 0.0193095 | 0.0250942 | 0.0237690 | 0.0295245 | 0.052373 | 100 |
| rowSums | 0.105131 | 0.1065075 | 0.1091586 | 0.1077885 | 0.1105690 | 0.131508 | 100 |
| apply+sum | 3.100086 | 3.1708005 | 3.3213949 | 3.2154925 | 3.3215920 | 4.163554 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 5.843533 | 5.515808 | 4.349955 | 4.534835 | 3.744991 | 2.510988 | 100 |
| apply+sum | 172.313157 | 164.209353 | 132.357075 | 135.280933 | 112.502904 | 79.498100 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on integer+10x1000 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 16.090 | 17.1900 | 22.6740 | 20.080 | 26.1005 | 40.684 | 100 |
| rowCounts | 17.991 | 19.3095 | 25.0942 | 23.769 | 29.5245 | 52.373 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.118148 | 1.123298 | 1.106739 | 1.183715 | 1.131185 | 1.287312 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x1000"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.102628 | 0.1047720 | 0.1154164 | 0.1142385 | 0.1261055 | 0.135459 | 100 |
| colSums | 0.801134 | 0.8090535 | 1.0734457 | 0.8200350 | 0.8711975 | 2.691553 | 100 |
| apply+sum | 4.710071 | 4.7907695 | 5.5991978 | 4.8378280 | 5.0479450 | 47.196851 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 100 |
| colSums | 7.806193 | 7.722039 | 9.300632 | 7.178272 | 6.908481 | 19.86987 | 100 |
| apply+sum | 45.894600 | 45.725666 | 48.513009 | 42.348490 | 40.029539 | 348.42167 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.124136 | 0.1270195 | 0.1359501 | 0.1363150 | 0.142851 | 0.155579 | 100 |
| rowSums | 0.961554 | 0.9696845 | 1.1350187 | 0.9757305 | 1.006057 | 2.769947 | 100 |
| apply+sum | 4.694080 | 4.8420400 | 5.4685971 | 4.9833810 | 6.396341 | 7.366662 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.00000 | 100 |
| rowSums | 7.745972 | 7.634139 | 8.348788 | 7.15791 | 7.042702 | 17.80412 | 100 |
| apply+sum | 37.814010 | 38.120446 | 40.225026 | 36.55783 | 44.776312 | 47.34998 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on integer+100x1000 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 102.628 | 104.7720 | 115.4164 | 114.2385 | 126.1055 | 135.459 | 100 |
| rowCounts | 124.136 | 127.0195 | 135.9501 | 136.3150 | 142.8510 | 155.579 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.00000 | 1.000000 | 100 |
| rowCounts | 1.209572 | 1.212342 | 1.17791 | 1.193249 | 1.13279 | 1.148532 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x100"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.095672 | 0.098738 | 0.1064356 | 0.1066160 | 0.111216 | 0.168510 | 100 |
| colSums | 0.794877 | 0.799742 | 1.3252402 | 0.8058195 | 0.834963 | 43.680496 | 100 |
| apply+sum | 1.962361 | 2.001254 | 2.2991458 | 2.0403005 | 2.882436 | 3.197454 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.00000 | 1.00000 | 100 |
| colSums | 8.308356 | 8.099637 | 12.45110 | 7.558148 | 7.50758 | 259.21605 | 100 |
| apply+sum | 20.511341 | 20.268331 | 21.60128 | 19.136907 | 25.91746 | 18.97486 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.129602 | 0.1312545 | 0.1378455 | 0.1356315 | 0.144935 | 0.158294 | 100 |
| rowSums | 0.967389 | 0.9709875 | 1.1009219 | 0.9746685 | 0.987880 | 1.985198 | 100 |
| apply+sum | 1.988194 | 2.0135090 | 2.2640658 | 2.0473515 | 2.456067 | 3.048246 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 100 |
| rowSums | 7.464306 | 7.397746 | 7.986636 | 7.186151 | 6.816021 | 12.54121 | 100 |
| apply+sum | 15.340766 | 15.340495 | 16.424662 | 15.094956 | 16.945990 | 19.25686 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on integer+1000x100 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 95.672 | 98.7380 | 106.4356 | 106.6160 | 111.216 | 168.510 | 100 |
| rowCounts | 129.602 | 131.2545 | 137.8455 | 135.6315 | 144.935 | 158.294 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.0000000 | 100 |
| rowCounts | 1.354649 | 1.329321 | 1.295107 | 1.27215 | 1.303185 | 0.9393745 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on integer+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> 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)> X <- data[["10x10"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.005936 | 0.0067245 | 0.0079858 | 0.0077115 | 0.008852 | 0.024094 | 100 |
| colSums | 0.007372 | 0.0082060 | 0.0092560 | 0.0094550 | 0.009833 | 0.018231 | 100 |
| apply+sum | 0.055647 | 0.0572880 | 0.0590818 | 0.0583645 | 0.059017 | 0.112597 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 100 |
| colSums | 1.241914 | 1.220314 | 1.159062 | 1.226091 | 1.110822 | 0.7566614 | 100 |
| apply+sum | 9.374495 | 8.519295 | 7.398353 | 7.568502 | 6.667081 | 4.6732382 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.006034 | 0.0067830 | 0.0079523 | 0.0073420 | 0.0088265 | 0.023782 | 100 |
| rowSums | 0.006896 | 0.0076980 | 0.0087938 | 0.0088325 | 0.0094700 | 0.015982 | 100 |
| apply+sum | 0.055437 | 0.0573025 | 0.0592130 | 0.0580355 | 0.0592000 | 0.114266 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.0000000 | 100 |
| rowSums | 1.142857 | 1.134896 | 1.105830 | 1.20301 | 1.072906 | 0.6720209 | 100 |
| apply+sum | 9.187438 | 8.447958 | 7.446059 | 7.90459 | 6.707075 | 4.8047263 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on double+10x10 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 6.034 | 6.7830 | 7.95226 | 7.3420 | 8.8265 | 23.782 | 100 |
| 1 | colCounts | 5.936 | 6.7245 | 7.98580 | 7.7115 | 8.8520 | 24.094 | 100 |
| expr | min | lq | mean | median | uq | max | neval | |
|---|---|---|---|---|---|---|---|---|
| 2 | rowCounts | 1.0000000 | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| 1 | colCounts | 0.9837587 | 0.9913755 | 1.004218 | 1.050327 | 1.002889 | 1.013119 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x100"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.034769 | 0.0361295 | 0.0386138 | 0.0381915 | 0.0391920 | 0.064935 | 100 |
| colSums | 0.078908 | 0.0798225 | 0.0819926 | 0.0809350 | 0.0820820 | 0.095816 | 100 |
| apply+sum | 0.454868 | 0.4620650 | 0.5110225 | 0.4718755 | 0.4865935 | 2.280414 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.269493 | 2.209344 | 2.12340 | 2.119189 | 2.094356 | 1.475568 | 100 |
| apply+sum | 13.082574 | 12.789134 | 13.23418 | 12.355511 | 12.415633 | 35.118411 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.043411 | 0.044414 | 0.0467659 | 0.046210 | 0.0469590 | 0.068058 | 100 |
| rowSums | 0.094850 | 0.096010 | 0.1142993 | 0.096805 | 0.0973495 | 1.748354 | 100 |
| apply+sum | 0.455404 | 0.461539 | 0.4849037 | 0.464896 | 0.4720785 | 2.129474 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 100 |
| rowSums | 2.18493 | 2.161706 | 2.444074 | 2.094893 | 2.073074 | 25.68918 | 100 |
| apply+sum | 10.49052 | 10.391746 | 10.368746 | 10.060506 | 10.052993 | 31.28911 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on double+100x100 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 34.769 | 36.1295 | 38.61383 | 38.1915 | 39.192 | 64.935 | 100 |
| rowCounts | 43.411 | 44.4140 | 46.76590 | 46.2100 | 46.959 | 68.058 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.0000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.248555 | 1.2293 | 1.211118 | 1.209955 | 1.198178 | 1.048094 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x10"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.034373 | 0.0349355 | 0.0369176 | 0.036364 | 0.0372620 | 0.052782 | 100 |
| colSums | 0.078095 | 0.0787855 | 0.0807346 | 0.079753 | 0.0803150 | 0.121939 | 100 |
| apply+sum | 0.211868 | 0.2134145 | 0.2366454 | 0.214333 | 0.2164105 | 1.222975 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.271987 | 2.255170 | 2.186888 | 2.193186 | 2.155413 | 2.310238 | 100 |
| apply+sum | 6.163791 | 6.108815 | 6.410100 | 5.894099 | 5.807807 | 23.170304 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.044714 | 0.0457965 | 0.0491711 | 0.0479145 | 0.0496450 | 0.079371 | 100 |
| rowSums | 0.096121 | 0.0970720 | 0.0993996 | 0.0980085 | 0.0988460 | 0.114416 | 100 |
| apply+sum | 0.212571 | 0.2147905 | 0.2420802 | 0.2168910 | 0.2319675 | 1.194826 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.149685 | 2.119638 | 2.021503 | 2.045487 | 1.991057 | 1.441534 | 100 |
| apply+sum | 4.754014 | 4.690107 | 4.923218 | 4.526626 | 4.672525 | 15.053685 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on double+1000x10 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 34.373 | 34.9355 | 36.91759 | 36.3640 | 37.262 | 52.782 | 100 |
| rowCounts | 44.714 | 45.7965 | 49.17114 | 47.9145 | 49.645 | 79.371 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.300847 | 1.310887 | 1.331916 | 1.317636 | 1.332323 | 1.503751 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["10x1000"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.037057 | 0.0384665 | 0.0438680 | 0.0415665 | 0.0487650 | 0.061573 | 100 |
| colSums | 0.080396 | 0.0821550 | 0.0854611 | 0.0840240 | 0.0882245 | 0.102324 | 100 |
| apply+sum | 2.720326 | 2.7820100 | 2.9387916 | 2.8537620 | 2.9454385 | 3.949417 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.169523 | 2.135755 | 1.948144 | 2.021435 | 1.809177 | 1.661832 | 100 |
| apply+sum | 73.409234 | 72.322930 | 66.991754 | 68.655335 | 60.400666 | 64.142027 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.042923 | 0.0444465 | 0.0493494 | 0.0479680 | 0.0539025 | 0.071507 | 100 |
| rowSums | 0.096006 | 0.0973235 | 0.1001528 | 0.0988215 | 0.1022085 | 0.115077 | 100 |
| apply+sum | 2.729340 | 2.7744635 | 2.9178261 | 2.8183935 | 2.9185295 | 3.876591 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.236703 | 2.189678 | 2.029464 | 2.060155 | 1.896174 | 1.609311 | 100 |
| apply+sum | 63.586888 | 62.422542 | 59.125867 | 58.755702 | 54.144604 | 54.212748 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on double+10x1000 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 37.057 | 38.4665 | 43.86796 | 41.5665 | 48.7650 | 61.573 | 100 |
| rowCounts | 42.923 | 44.4465 | 49.34940 | 47.9680 | 53.9025 | 71.507 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.158297 | 1.15546 | 1.124953 | 1.154006 | 1.105352 | 1.161337 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["100x1000"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.295140 | 0.2969465 | 0.3087949 | 0.3070985 | 0.3171555 | 0.357848 | 100 |
| colSums | 0.714855 | 0.7171400 | 0.7795327 | 0.7264470 | 0.7355420 | 2.132311 | 100 |
| apply+sum | 4.280087 | 4.3487345 | 5.3278862 | 4.4174840 | 5.8508735 | 47.168773 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.422088 | 2.415048 | 2.524435 | 2.365518 | 2.319184 | 5.958706 | 100 |
| apply+sum | 14.501887 | 14.644842 | 17.253802 | 14.384583 | 18.447965 | 131.812314 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.371308 | 0.374305 | 0.3836680 | 0.382210 | 0.3900715 | 0.427003 | 100 |
| rowSums | 0.875715 | 0.878525 | 0.9894834 | 0.884685 | 0.8998235 | 2.553067 | 100 |
| apply+sum | 4.332604 | 4.422945 | 5.0157825 | 4.582655 | 5.9243640 | 6.633233 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.35846 | 2.347083 | 2.579009 | 2.314657 | 2.306817 | 5.979038 | 100 |
| apply+sum | 11.66849 | 11.816420 | 13.073235 | 11.989888 | 15.187893 | 15.534394 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on double+100x1000 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 295.140 | 296.9465 | 308.7949 | 307.0985 | 317.1555 | 357.848 | 100 |
| rowCounts | 371.308 | 374.3050 | 383.6680 | 382.2100 | 390.0715 | 427.003 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.258074 | 1.260513 | 1.242469 | 1.244584 | 1.229906 | 1.193252 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

> X <- data[["1000x100"]]
> value <- 42> colStats <- microbenchmark(colCounts = colCounts(X, value = value, na.rm = FALSE), colSums = colSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 2L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")> X <- t(X)> rowStats <- microbenchmark(rowCounts = rowCounts(X, value = value, na.rm = FALSE), rowSums = rowSums(X ==
+ value, na.rm = FALSE), `apply+sum` = apply(X, MARGIN = 1L, FUN = function(x) sum(x == value,
+ na.rm = FALSE)), unit = "ms")Table: Benchmarking of colCounts(), colSums() and apply+sum() 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 | 0.287993 | 0.2892030 | 0.2994595 | 0.2959355 | 0.3058125 | 0.351222 | 100 |
| colSums | 0.708476 | 0.7099995 | 0.7534923 | 0.7157475 | 0.7262620 | 1.709930 | 100 |
| apply+sum | 1.848825 | 1.8611890 | 2.5727953 | 1.8875580 | 2.7690475 | 43.493654 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| colSums | 2.460046 | 2.455021 | 2.516174 | 2.418593 | 2.374860 | 4.868516 | 100 |
| apply+sum | 6.419687 | 6.435580 | 8.591462 | 6.378275 | 9.054723 | 123.835221 | 100 |
| Table: Benchmarking of rowCounts(), rowSums() and apply+sum() 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 | 0.377871 | 0.380023 | 0.3891483 | 0.385470 | 0.3955075 | 0.418472 | 100 |
| rowSums | 0.881318 | 0.883883 | 0.9300696 | 0.887365 | 0.9021165 | 1.861215 | 100 |
| apply+sum | 1.879640 | 1.907911 | 2.6588699 | 1.943134 | 2.8218000 | 44.852003 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowSums | 2.332325 | 2.325867 | 2.390013 | 2.302034 | 2.280909 | 4.447645 | 100 |
| apply+sum | 4.974290 | 5.020516 | 6.832536 | 5.040949 | 7.134631 | 107.180416 | 100 |
| Figure: Benchmarking of colCounts(), colSums() and apply+sum() on double+1000x100 data as well as rowCounts(), rowSums() and apply+sum() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds. |
Table: Benchmarking of colCounts() and rowCounts() 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 | 287.993 | 289.203 | 299.4595 | 295.9355 | 305.8125 | 351.222 | 100 |
| rowCounts | 377.871 | 380.023 | 389.1483 | 385.4700 | 395.5075 | 418.472 | 100 |
| expr | min | lq | mean | median | uq | max | neval |
|---|---|---|---|---|---|---|---|
| colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 100 |
| rowCounts | 1.312084 | 1.314035 | 1.299502 | 1.302547 | 1.293301 | 1.191474 | 100 |
| Figure: Benchmarking of colCounts() and rowCounts() on double+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds. |

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] markdown_0.7.4 microbenchmark_1.4-2 matrixStats_0.14.0
[4] ggplot2_1.0.1 knitr_1.9 R.devices_2.13.0
[7] R.utils_2.0.0 R.oo_1.19.0 R.methodsS3_1.7.0
loaded via a namespace (and not attached):
[1] base64enc_0.1-2 colorspace_1.2-6 digest_0.6.8 evaluate_0.5.5
[5] formatR_1.1 grid_3.0.2 gtable_0.1.2 labeling_0.3
[9] MASS_7.3-29 mime_0.2 munsell_0.4.2 plyr_1.8.1
[13] proto_0.3-10 R.cache_0.10.0 Rcpp_0.11.5 reshape2_1.4.1
[17] R.rsp_0.20.0 scales_0.2.4 stringr_0.6.2 tools_3.0.2 Total processing time was 23.32 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colCounts')Copyright Henrik Bengtsson. Last updated on 2015-04-18 19:54:09 (+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)