-
Notifications
You must be signed in to change notification settings - Fork 34
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), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)
> 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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.002328 | 0.0026845 | 0.0034006 | 0.0031785 | 0.0036755 | 0.020089 |
2 | colSums | 0.003611 | 0.0042750 | 0.0050358 | 0.0048795 | 0.0054905 | 0.018323 |
3 | apply+sum | 0.023981 | 0.0250105 | 0.0268431 | 0.0256210 | 0.0263100 | 0.115911 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.0000000 |
2 | colSums | 1.551117 | 1.592475 | 1.480874 | 1.535158 | 1.49381 | 0.9120912 |
3 | apply+sum | 10.301117 | 9.316633 | 7.893680 | 8.060721 | 7.15821 | 5.7698741 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.002142 | 0.0025260 | 0.0031219 | 0.0030625 | 0.0033300 | 0.019303 |
2 | rowSums | 0.004027 | 0.0047025 | 0.0052483 | 0.0051865 | 0.0055520 | 0.013782 |
3 | apply+sum | 0.023156 | 0.0238310 | 0.0255243 | 0.0243485 | 0.0249995 | 0.113094 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowSums | 1.880019 | 1.861639 | 1.681142 | 1.693551 | 1.667267 | 0.7139823 |
3 | apply+sum | 10.810458 | 9.434283 | 8.175985 | 7.950531 | 7.507357 | 5.8588820 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 2.142 | 2.5260 | 3.12186 | 3.0625 | 3.3300 | 19.303 |
1 | colCounts | 2.328 | 2.6845 | 3.40058 | 3.1785 | 3.6755 | 20.089 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 |
1 | colCounts | 1.086835 | 1.062747 | 1.08928 | 1.037878 | 1.103754 | 1.040719 |
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 | |
---|---|---|---|---|---|---|---|
2 | colSums | 0.028677 | 0.0319080 | 0.0339170 | 0.033191 | 0.0347105 | 0.083212 |
1 | colCounts | 0.036823 | 0.0406280 | 0.0427344 | 0.043041 | 0.0445850 | 0.055337 |
3 | apply+sum | 0.249355 | 0.2666405 | 0.2764543 | 0.276950 | 0.2815840 | 0.369515 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | colSums | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
1 | colCounts | 1.284060 | 1.273286 | 1.259971 | 1.296767 | 1.284482 | 0.6650123 |
3 | apply+sum | 8.695296 | 8.356541 | 8.150916 | 8.344129 | 8.112358 | 4.4406456 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.039630 | 0.0419400 | 0.0438029 | 0.0435405 | 0.0449350 | 0.060316 |
2 | rowSums | 0.052529 | 0.0549360 | 0.0574219 | 0.0569215 | 0.0584745 | 0.095847 |
3 | apply+sum | 0.201360 | 0.2126885 | 0.2198666 | 0.2181190 | 0.2247705 | 0.316050 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 1.325486 | 1.309871 | 1.310915 | 1.307323 | 1.301313 | 1.589081 |
3 | apply+sum | 5.080999 | 5.071257 | 5.019455 | 5.009566 | 5.002125 | 5.239903 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 36.823 | 40.628 | 42.73438 | 43.0410 | 44.585 | 55.337 |
2 | rowCounts | 39.630 | 41.940 | 43.80289 | 43.5405 | 44.935 | 60.316 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 |
2 | rowCounts | 1.076229 | 1.032293 | 1.025003 | 1.011605 | 1.00785 | 1.089976 |
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 | |
---|---|---|---|---|---|---|---|
2 | colSums | 0.028710 | 0.0302335 | 0.0321662 | 0.0309535 | 0.0324555 | 0.079907 |
1 | colCounts | 0.035595 | 0.0385470 | 0.0397576 | 0.0393385 | 0.0409075 | 0.056743 |
3 | apply+sum | 0.137407 | 0.1414435 | 0.1456927 | 0.1446505 | 0.1482805 | 0.192041 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | colSums | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | colCounts | 1.239812 | 1.274976 | 1.236005 | 1.270890 | 1.260418 | 0.710113 |
3 | apply+sum | 4.786033 | 4.678370 | 4.529368 | 4.673155 | 4.568733 | 2.403306 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.042749 | 0.0442715 | 0.0460280 | 0.0453575 | 0.046274 | 0.086405 |
3 | apply+sum | 0.090446 | 0.0961030 | 0.0993340 | 0.0975900 | 0.100060 | 0.165663 |
2 | rowSums | 0.150703 | 0.1518345 | 0.1538293 | 0.1525445 | 0.154458 | 0.169657 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+sum | 2.115745 | 2.170765 | 2.158122 | 2.151574 | 2.162337 | 1.917285 |
2 | rowSums | 3.525299 | 3.429622 | 3.342081 | 3.363159 | 3.337900 | 1.963509 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 35.595 | 38.5470 | 39.75761 | 39.3385 | 40.9075 | 56.743 |
2 | rowCounts | 42.749 | 44.2715 | 46.02800 | 45.3575 | 46.2740 | 86.405 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowCounts | 1.200983 | 1.148507 | 1.157715 | 1.153005 | 1.131186 | 1.522743 |
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 | |
---|---|---|---|---|---|---|---|
2 | colSums | 0.030470 | 0.0347585 | 0.0369110 | 0.035816 | 0.0379420 | 0.094213 |
1 | colCounts | 0.048898 | 0.0507590 | 0.0533154 | 0.052875 | 0.0544615 | 0.071200 |
3 | apply+sum | 1.152888 | 1.3644255 | 1.4148292 | 1.416287 | 1.4737975 | 1.647667 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | colSums | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
1 | colCounts | 1.604792 | 1.460333 | 1.444431 | 1.476295 | 1.435388 | 0.7557343 |
3 | apply+sum | 37.836823 | 39.254441 | 38.330819 | 39.543416 | 38.843432 | 17.4887436 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.040192 | 0.046462 | 0.0480386 | 0.0479915 | 0.0494305 | 0.057295 |
2 | rowSums | 0.045889 | 0.050253 | 0.0518240 | 0.0512735 | 0.0527490 | 0.083858 |
3 | apply+sum | 1.144308 | 1.334182 | 1.3896115 | 1.3898330 | 1.4537275 | 1.626345 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 1.141745 | 1.081594 | 1.078799 | 1.068387 | 1.067135 | 1.463618 |
3 | apply+sum | 28.471039 | 28.715553 | 28.926964 | 28.959982 | 29.409524 | 28.385461 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 40.192 | 46.462 | 48.03862 | 47.9915 | 49.4305 | 57.295 |
1 | colCounts | 48.898 | 50.759 | 53.31541 | 52.8750 | 54.4615 | 71.200 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | colCounts | 1.21661 | 1.092484 | 1.109845 | 1.101758 | 1.101779 | 1.242691 |
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 | |
---|---|---|---|---|---|---|---|
2 | colSums | 0.251793 | 0.278771 | 0.2837448 | 0.282931 | 0.2886400 | 0.373711 |
1 | colCounts | 0.367332 | 0.411473 | 0.4158703 | 0.414132 | 0.4252835 | 0.453008 |
3 | apply+sum | 2.358500 | 2.597695 | 2.7831135 | 2.643990 | 2.6813615 | 17.475270 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | colSums | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | colCounts | 1.458865 | 1.476025 | 1.465649 | 1.463721 | 1.473405 | 1.212188 |
3 | apply+sum | 9.366821 | 9.318383 | 9.808508 | 9.344999 | 9.289639 | 46.761455 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.381769 | 0.423853 | 0.4341455 | 0.434970 | 0.4390095 | 0.594224 |
2 | rowSums | 0.393760 | 0.443222 | 0.4479370 | 0.446323 | 0.4558705 | 0.584000 |
3 | apply+sum | 1.911745 | 2.104206 | 2.2907912 | 2.135264 | 2.1851250 | 17.030164 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowSums | 1.031409 | 1.045697 | 1.031767 | 1.026101 | 1.038407 | 0.9827944 |
3 | apply+sum | 5.007596 | 4.964471 | 5.276551 | 4.908991 | 4.977398 | 28.6595021 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 367.332 | 411.473 | 415.8703 | 414.132 | 425.2835 | 453.008 |
2 | rowCounts | 381.769 | 423.853 | 434.1455 | 434.970 | 439.0095 | 594.224 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | rowCounts | 1.039302 | 1.030087 | 1.043945 | 1.050317 | 1.032275 | 1.31173 |
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 | |
---|---|---|---|---|---|---|---|
2 | colSums | 0.246997 | 0.2684990 | 0.3471783 | 0.2780810 | 0.2879720 | 7.077920 |
1 | colCounts | 0.350538 | 0.3812510 | 0.3936804 | 0.3929965 | 0.4051735 | 0.465459 |
3 | apply+sum | 0.795796 | 0.8459175 | 0.8681194 | 0.8652085 | 0.8879385 | 1.033500 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | colSums | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
1 | colCounts | 1.419199 | 1.419935 | 1.133943 | 1.413245 | 1.406989 | 0.0657621 |
3 | apply+sum | 3.221885 | 3.150542 | 2.500500 | 3.111354 | 3.083420 | 0.1460175 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.383917 | 0.4188915 | 0.4288461 | 0.4291130 | 0.4403380 | 0.497454 |
2 | rowSums | 0.490445 | 0.5427390 | 0.5491929 | 0.5447770 | 0.5591100 | 0.625087 |
3 | apply+sum | 0.867725 | 0.8985720 | 0.9925708 | 0.9146845 | 0.9323115 | 7.680937 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 1.277477 | 1.295655 | 1.280629 | 1.269542 | 1.269729 | 1.256573 |
3 | apply+sum | 2.260189 | 2.145119 | 2.314515 | 2.131570 | 2.117263 | 15.440497 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 350.538 | 381.2510 | 393.6804 | 392.9965 | 405.1735 | 465.459 |
2 | rowCounts | 383.917 | 418.8915 | 428.8461 | 429.1130 | 440.3380 | 497.454 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.0000 | 1.000000 | 1.000000 |
2 | rowCounts | 1.095222 | 1.098729 | 1.089325 | 1.0919 | 1.086789 | 1.068739 |
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), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)
> 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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.002294 | 0.0027695 | 0.0033275 | 0.0031695 | 0.0035730 | 0.018437 |
2 | colSums | 0.003521 | 0.0042510 | 0.0050100 | 0.0047865 | 0.0053525 | 0.018981 |
3 | apply+sum | 0.023711 | 0.0244435 | 0.0260772 | 0.0249880 | 0.0254990 | 0.110113 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | colSums | 1.534874 | 1.534934 | 1.505642 | 1.510175 | 1.498041 | 1.029506 |
3 | apply+sum | 10.336094 | 8.825961 | 7.836960 | 7.883893 | 7.136580 | 5.972392 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.002224 | 0.0025580 | 0.0031205 | 0.003065 | 0.003297 | 0.019767 |
2 | rowSums | 0.004278 | 0.0046755 | 0.0052453 | 0.005149 | 0.005538 | 0.013490 |
3 | apply+sum | 0.023192 | 0.0241550 | 0.0258686 | 0.024641 | 0.025128 | 0.115457 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowSums | 1.923561 | 1.827795 | 1.680907 | 1.679935 | 1.679709 | 0.6824505 |
3 | apply+sum | 10.428058 | 9.442924 | 8.289889 | 8.039478 | 7.621474 | 5.8408964 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 2.224 | 2.5580 | 3.12050 | 3.0650 | 3.297 | 19.767 |
1 | colCounts | 2.294 | 2.7695 | 3.32747 | 3.1695 | 3.573 | 18.437 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
1 | colCounts | 1.031475 | 1.082682 | 1.066326 | 1.034095 | 1.083713 | 0.9327161 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.009680 | 0.0109585 | 0.0118371 | 0.011584 | 0.0122145 | 0.026120 |
2 | colSums | 0.028641 | 0.0305650 | 0.0325819 | 0.032243 | 0.0333430 | 0.068816 |
3 | apply+sum | 0.202369 | 0.2136885 | 0.2224504 | 0.220758 | 0.2277980 | 0.314136 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | colSums | 2.958781 | 2.789159 | 2.752523 | 2.783408 | 2.729788 | 2.634609 |
3 | apply+sum | 20.905888 | 19.499795 | 18.792643 | 19.057148 | 18.649801 | 12.026646 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.009782 | 0.0107015 | 0.0116533 | 0.0115075 | 0.012229 | 0.025980 |
2 | rowSums | 0.052254 | 0.0543355 | 0.0570388 | 0.0568945 | 0.058840 | 0.082481 |
3 | apply+sum | 0.198398 | 0.2091705 | 0.2170734 | 0.2168195 | 0.220956 | 0.291754 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 5.341852 | 5.077372 | 4.894644 | 4.944123 | 4.811514 | 3.174788 |
3 | apply+sum | 20.281946 | 19.545905 | 18.627605 | 18.841582 | 18.068199 | 11.229946 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 9.782 | 10.7015 | 11.65332 | 11.5075 | 12.2290 | 25.98 |
1 | colCounts | 9.680 | 10.9585 | 11.83710 | 11.5840 | 12.2145 | 26.12 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 |
1 | colCounts | 0.9895727 | 1.024015 | 1.015771 | 1.006648 | 0.9988143 | 1.005389 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.008485 | 0.0091530 | 0.0100014 | 0.0096835 | 0.0102135 | 0.026648 |
2 | colSums | 0.028789 | 0.0297235 | 0.0312879 | 0.0304580 | 0.0314395 | 0.078758 |
3 | apply+sum | 0.094330 | 0.0970910 | 0.1004045 | 0.0986365 | 0.1004485 | 0.154553 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 |
2 | colSums | 3.392929 | 3.247405 | 3.128366 | 3.14535 | 3.078230 | 2.955494 |
3 | apply+sum | 11.117266 | 10.607560 | 10.039082 | 10.18604 | 9.834875 | 5.799797 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.009922 | 0.010539 | 0.0120016 | 0.0113540 | 0.0118370 | 0.048509 |
3 | apply+sum | 0.092502 | 0.095798 | 0.1002758 | 0.0967795 | 0.0998375 | 0.183271 |
2 | rowSums | 0.150489 | 0.151916 | 0.1576946 | 0.1550520 | 0.1577745 | 0.249131 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+sum | 9.322919 | 9.089857 | 8.355213 | 8.523824 | 8.434358 | 3.778082 |
2 | rowSums | 15.167204 | 14.414650 | 13.139489 | 13.656156 | 13.328926 | 5.135769 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 8.485 | 9.153 | 10.00136 | 9.6835 | 10.2135 | 26.648 |
2 | rowCounts | 9.922 | 10.539 | 12.00158 | 11.3540 | 11.8370 | 48.509 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 |
2 | rowCounts | 1.169358 | 1.151426 | 1.199995 | 1.17251 | 1.158956 | 1.820362 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.013271 | 0.0144885 | 0.0166902 | 0.0155940 | 0.0182175 | 0.036133 |
2 | colSums | 0.030669 | 0.0344525 | 0.0374436 | 0.0356975 | 0.0384700 | 0.083503 |
3 | apply+sum | 1.143084 | 1.3664885 | 1.4343462 | 1.4163240 | 1.4798550 | 1.910101 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | colSums | 2.310979 | 2.37792 | 2.243454 | 2.289182 | 2.111706 | 2.31099 |
3 | apply+sum | 86.133976 | 94.31539 | 85.939578 | 90.824933 | 81.232606 | 52.86306 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.009825 | 0.011479 | 0.0127799 | 0.0126325 | 0.0135450 | 0.025046 |
2 | rowSums | 0.047333 | 0.050072 | 0.0513539 | 0.0510790 | 0.0521535 | 0.064745 |
3 | apply+sum | 1.121708 | 1.333550 | 1.3801187 | 1.3870145 | 1.4488205 | 1.596805 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 4.817608 | 4.362052 | 4.018324 | 4.043459 | 3.850388 | 2.585043 |
3 | apply+sum | 114.168753 | 116.173012 | 107.991099 | 109.797308 | 106.963492 | 63.754891 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 9.825 | 11.4790 | 12.77993 | 12.6325 | 13.5450 | 25.046 |
1 | colCounts | 13.271 | 14.4885 | 16.69017 | 15.5940 | 18.2175 | 36.133 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | colCounts | 1.350738 | 1.262174 | 1.305967 | 1.234435 | 1.344961 | 1.442665 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.077557 | 0.0839765 | 0.0875862 | 0.0866995 | 0.0897325 | 0.131382 |
2 | colSums | 0.244317 | 0.2777990 | 0.2820857 | 0.2842420 | 0.2903470 | 0.311446 |
3 | apply+sum | 1.911778 | 2.0975750 | 2.2806285 | 2.1376915 | 2.1812515 | 16.733862 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | colSums | 3.150161 | 3.308056 | 3.220665 | 3.278473 | 3.235695 | 2.370538 |
3 | apply+sum | 24.649974 | 24.978119 | 26.038688 | 24.656330 | 24.308378 | 127.367996 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.066644 | 0.074960 | 0.0777305 | 0.0771330 | 0.0793215 | 0.097746 |
2 | rowSums | 0.395390 | 0.448138 | 0.4542746 | 0.4581175 | 0.4610180 | 0.498521 |
3 | apply+sum | 1.930299 | 2.111248 | 2.2927815 | 2.1475750 | 2.1861240 | 16.694900 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 5.932867 | 5.978362 | 5.844227 | 5.939319 | 5.812018 | 5.100168 |
3 | apply+sum | 28.964333 | 28.164995 | 29.496549 | 27.842493 | 27.560296 | 170.798805 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 66.644 | 74.9600 | 77.73050 | 77.1330 | 79.3215 | 97.746 |
1 | colCounts | 77.557 | 83.9765 | 87.58615 | 86.6995 | 89.7325 | 131.382 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | colCounts | 1.163751 | 1.120284 | 1.126793 | 1.124026 | 1.131251 | 1.344116 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.062391 | 0.0709410 | 0.0731314 | 0.0727470 | 0.0747695 | 0.097505 |
2 | colSums | 0.250656 | 0.2761615 | 0.3521502 | 0.2848915 | 0.2939970 | 7.008896 |
3 | apply+sum | 0.820201 | 0.8754505 | 0.8908282 | 0.8886385 | 0.9077550 | 1.048810 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.00000 |
2 | colSums | 4.017502 | 3.892834 | 4.81531 | 3.916196 | 3.932044 | 71.88243 |
3 | apply+sum | 13.146143 | 12.340544 | 12.18120 | 12.215466 | 12.140712 | 10.75647 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.077440 | 0.0868970 | 0.0913577 | 0.0894245 | 0.0918630 | 0.259978 |
2 | rowSums | 0.489164 | 0.5421850 | 0.5558072 | 0.5589465 | 0.5721430 | 0.675897 |
3 | apply+sum | 0.828744 | 0.8977505 | 0.9865928 | 0.9072540 | 0.9307245 | 7.791024 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.00000 | 1.000000 |
2 | rowSums | 6.316684 | 6.239398 | 6.08386 | 6.250485 | 6.22822 | 2.599824 |
3 | apply+sum | 10.701756 | 10.331202 | 10.79923 | 10.145475 | 10.13166 | 29.968013 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 62.391 | 70.941 | 73.13138 | 72.7470 | 74.7695 | 97.505 |
2 | rowCounts | 77.440 | 86.897 | 91.35766 | 89.4245 | 91.8630 | 259.978 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowCounts | 1.241205 | 1.224919 | 1.249227 | 1.229253 | 1.228616 | 2.666304 |
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), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)
> 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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.002400 | 0.002824 | 0.0033545 | 0.0032355 | 0.0036150 | 0.015873 |
2 | colSums | 0.003528 | 0.004263 | 0.0049980 | 0.0048640 | 0.0054525 | 0.017406 |
3 | apply+sum | 0.024579 | 0.025424 | 0.0273306 | 0.0261875 | 0.0268355 | 0.098683 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | colSums | 1.47000 | 1.509561 | 1.489945 | 1.503322 | 1.508299 | 1.096579 |
3 | apply+sum | 10.24125 | 9.002833 | 8.147501 | 8.093803 | 7.423375 | 6.217035 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.002119 | 0.0024580 | 0.0030468 | 0.0030460 | 0.0033125 | 0.016031 |
2 | rowSums | 0.004028 | 0.0045980 | 0.0051230 | 0.0049595 | 0.0054595 | 0.012398 |
3 | apply+sum | 0.022943 | 0.0238265 | 0.0250884 | 0.0241670 | 0.0247565 | 0.082336 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowSums | 1.900897 | 1.870626 | 1.681399 | 1.628201 | 1.648151 | 0.7733766 |
3 | apply+sum | 10.827277 | 9.693450 | 8.234203 | 7.934012 | 7.473660 | 5.1360489 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 2.119 | 2.458 | 3.04685 | 3.0460 | 3.3125 | 16.031 |
1 | colCounts | 2.400 | 2.824 | 3.35448 | 3.2355 | 3.6150 | 15.873 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
1 | colCounts | 1.13261 | 1.148902 | 1.100967 | 1.062213 | 1.091321 | 0.9901441 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.013077 | 0.0143520 | 0.0150193 | 0.0148825 | 0.0156385 | 0.027298 |
2 | colSums | 0.024183 | 0.0256325 | 0.0271621 | 0.0268515 | 0.0278580 | 0.057314 |
3 | apply+sum | 0.241223 | 0.2513305 | 0.2632340 | 0.2645980 | 0.2703540 | 0.332537 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | colSums | 1.849277 | 1.785988 | 1.808484 | 1.804233 | 1.781373 | 2.099568 |
3 | apply+sum | 18.446356 | 17.511880 | 17.526415 | 17.779137 | 17.287719 | 12.181735 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.013647 | 0.0148050 | 0.0159620 | 0.0156780 | 0.0165370 | 0.032710 |
2 | rowSums | 0.048004 | 0.0501075 | 0.0526763 | 0.0529405 | 0.0542335 | 0.091946 |
3 | apply+sum | 0.197127 | 0.2090720 | 0.2178631 | 0.2183785 | 0.2224440 | 0.312596 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 3.51755 | 3.384498 | 3.300104 | 3.376738 | 3.279525 | 2.810945 |
3 | apply+sum | 14.44471 | 14.121716 | 13.648853 | 13.928977 | 13.451291 | 9.556588 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 13.077 | 14.352 | 15.01927 | 14.8825 | 15.6385 | 27.298 |
2 | rowCounts | 13.647 | 14.805 | 15.96201 | 15.6780 | 16.5370 | 32.710 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowCounts | 1.043588 | 1.031564 | 1.062769 | 1.053452 | 1.057454 | 1.198256 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.012190 | 0.0131750 | 0.0140944 | 0.0137900 | 0.0143500 | 0.028055 |
2 | colSums | 0.023972 | 0.0253625 | 0.0268999 | 0.0263130 | 0.0275100 | 0.051356 |
3 | apply+sum | 0.133603 | 0.1370685 | 0.1438736 | 0.1440655 | 0.1486545 | 0.184863 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | colSums | 1.96653 | 1.925047 | 1.908552 | 1.908122 | 1.917073 | 1.830547 |
3 | apply+sum | 10.96005 | 10.403681 | 10.207848 | 10.447099 | 10.359199 | 6.589307 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.013342 | 0.014339 | 0.0152904 | 0.0147195 | 0.0152260 | 0.046777 |
3 | apply+sum | 0.091434 | 0.094447 | 0.0971692 | 0.0967245 | 0.0978970 | 0.166123 |
2 | rowSums | 0.144738 | 0.147814 | 0.1532645 | 0.1543355 | 0.1552815 | 0.182930 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | apply+sum | 6.853096 | 6.586722 | 6.354906 | 6.571181 | 6.429594 | 3.551382 |
2 | rowSums | 10.848299 | 10.308529 | 10.023564 | 10.485105 | 10.198443 | 3.910683 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 12.190 | 13.175 | 14.09441 | 13.7900 | 14.350 | 28.055 |
2 | rowCounts | 13.342 | 14.339 | 15.29042 | 14.7195 | 15.226 | 46.777 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowCounts | 1.094504 | 1.088349 | 1.084857 | 1.067404 | 1.061045 | 1.667332 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.015487 | 0.0167375 | 0.0179957 | 0.0177835 | 0.0185205 | 0.029386 |
2 | colSums | 0.025288 | 0.0288670 | 0.0304565 | 0.0298915 | 0.0315220 | 0.052157 |
3 | apply+sum | 1.128363 | 1.3575160 | 1.3910470 | 1.3982795 | 1.4497070 | 1.595142 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | colSums | 1.632853 | 1.72469 | 1.692434 | 1.680856 | 1.702006 | 1.774893 |
3 | apply+sum | 72.858720 | 81.10626 | 77.298898 | 78.627914 | 78.275802 | 54.282379 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.014309 | 0.0162555 | 0.0176940 | 0.0173895 | 0.018379 | 0.030320 |
2 | rowSums | 0.038846 | 0.0451725 | 0.0468241 | 0.0465485 | 0.047673 | 0.063300 |
3 | apply+sum | 1.138963 | 1.3534980 | 1.3938169 | 1.4042220 | 1.454298 | 1.630223 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 2.714795 | 2.778906 | 2.646327 | 2.676817 | 2.593884 | 2.087731 |
3 | apply+sum | 79.597666 | 83.264003 | 78.773378 | 80.751143 | 79.128271 | 53.767249 |
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 | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 14.309 | 16.2555 | 17.69401 | 17.3895 | 18.3790 | 30.320 |
1 | colCounts | 15.487 | 16.7375 | 17.99569 | 17.7835 | 18.5205 | 29.386 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowCounts | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.0000000 |
1 | colCounts | 1.082326 | 1.029651 | 1.01705 | 1.022657 | 1.007699 | 0.9691953 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.106030 | 0.1215205 | 0.1270202 | 0.1230815 | 0.130991 | 0.194324 |
2 | colSums | 0.205654 | 0.2300105 | 0.3694346 | 0.2353750 | 0.244164 | 13.281108 |
3 | apply+sum | 2.331110 | 2.5964585 | 2.7965672 | 2.6262150 | 2.672417 | 16.346528 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | colSums | 1.939583 | 1.892771 | 2.908472 | 1.912351 | 1.863975 | 68.34518 |
3 | apply+sum | 21.985381 | 21.366424 | 22.016716 | 21.337203 | 20.401531 | 84.11996 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.110568 | 0.1244755 | 0.1309001 | 0.129068 | 0.1337675 | 0.175034 |
2 | rowSums | 0.346945 | 0.3912795 | 0.4061822 | 0.402256 | 0.4198065 | 0.477486 |
3 | apply+sum | 1.912307 | 2.1099115 | 2.4360798 | 2.150076 | 2.1997965 | 15.678354 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 |
2 | rowSums | 3.137843 | 3.143426 | 3.102993 | 3.116621 | 3.13833 | 2.727961 |
3 | apply+sum | 17.295302 | 16.950416 | 18.610215 | 16.658479 | 16.44493 | 89.573191 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 106.030 | 121.5205 | 127.0202 | 123.0815 | 130.9910 | 194.324 |
2 | rowCounts | 110.568 | 124.4755 | 130.9001 | 129.0680 | 133.7675 | 175.034 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowCounts | 1.042799 | 1.024317 | 1.030546 | 1.048639 | 1.021196 | 0.9007328 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 0.099038 | 0.1137430 | 0.1152469 | 0.1154190 | 0.1176060 | 0.129126 |
2 | colSums | 0.200269 | 0.2308030 | 0.2927586 | 0.2363550 | 0.2418085 | 5.926186 |
3 | apply+sum | 0.798039 | 0.8596005 | 0.9269429 | 0.8695245 | 0.8835600 | 6.472874 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | colSums | 2.022143 | 2.029162 | 2.540272 | 2.047800 | 2.056090 | 45.89460 |
3 | apply+sum | 8.057907 | 7.557392 | 8.043102 | 7.533634 | 7.512882 | 50.12836 |
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 | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 0.115612 | 0.1307065 | 0.1348954 | 0.1355175 | 0.137661 | 0.186606 |
2 | rowSums | 0.442426 | 0.5029895 | 0.5149004 | 0.5174200 | 0.521725 | 0.911519 |
3 | apply+sum | 0.850686 | 0.8945170 | 1.0342045 | 0.9017175 | 0.923892 | 6.506540 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowCounts | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowSums | 3.826817 | 3.848236 | 3.817036 | 3.818105 | 3.789926 | 4.884725 |
3 | apply+sum | 7.358112 | 6.843707 | 7.666716 | 6.653882 | 6.711356 | 34.867796 |
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 | |
---|---|---|---|---|---|---|---|
1 | colCounts | 99.038 | 113.7430 | 115.2469 | 115.4190 | 117.606 | 129.126 |
2 | rowCounts | 115.612 | 130.7065 | 134.8954 | 135.5175 | 137.661 | 186.606 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colCounts | 1.00000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowCounts | 1.16735 | 1.149139 | 1.17049 | 1.174135 | 1.170527 | 1.445147 |
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.6.1 Patched (2019-08-27 r77078)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] microbenchmark_1.4-6 matrixStats_0.55.0-9000 ggplot2_3.2.1
[4] knitr_1.24 R.devices_2.16.0 R.utils_2.9.0
[7] R.oo_1.22.0 R.methodsS3_1.7.1 history_0.0.0-9002
loaded via a namespace (and not attached):
[1] Biobase_2.45.0 bit64_0.9-7 splines_3.6.1
[4] network_1.15 assertthat_0.2.1 highr_0.8
[7] stats4_3.6.1 blob_1.2.0 robustbase_0.93-5
[10] pillar_1.4.2 RSQLite_2.1.2 backports_1.1.4
[13] lattice_0.20-38 glue_1.3.1 digest_0.6.20
[16] colorspace_1.4-1 sandwich_2.5-1 Matrix_1.2-17
[19] XML_3.98-1.20 lpSolve_5.6.13.3 pkgconfig_2.0.2
[22] genefilter_1.66.0 purrr_0.3.2 ergm_3.10.4
[25] xtable_1.8-4 mvtnorm_1.0-11 scales_1.0.0
[28] tibble_2.1.3 annotate_1.62.0 IRanges_2.18.2
[31] TH.data_1.0-10 withr_2.1.2 BiocGenerics_0.30.0
[34] lazyeval_0.2.2 mime_0.7 survival_2.44-1.1
[37] magrittr_1.5 crayon_1.3.4 statnet.common_4.3.0
[40] memoise_1.1.0 laeken_0.5.0 R.cache_0.13.0
[43] MASS_7.3-51.4 R.rsp_0.43.1 tools_3.6.1
[46] multcomp_1.4-10 S4Vectors_0.22.1 trust_0.1-7
[49] munsell_0.5.0 AnnotationDbi_1.46.1 compiler_3.6.1
[52] rlang_0.4.0 grid_3.6.1 RCurl_1.95-4.12
[55] cwhmisc_6.6 rappdirs_0.3.1 labeling_0.3
[58] bitops_1.0-6 base64enc_0.1-3 boot_1.3-23
[61] gtable_0.3.0 codetools_0.2-16 DBI_1.0.0
[64] markdown_1.1 R6_2.4.0 zoo_1.8-6
[67] dplyr_0.8.3 bit_1.1-14 zeallot_0.1.0
[70] parallel_3.6.1 Rcpp_1.0.2 vctrs_0.2.0
[73] DEoptimR_1.0-8 tidyselect_0.2.5 xfun_0.9
[76] coda_0.19-3
Total processing time was 37.43 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colCounts')
Copyright Henrik Bengtsson. Last updated on 2019-09-10 20:37:25 (-0700 UTC). Powered by RSP.
<script> var link = document.createElement('link'); link.rel = 'icon'; link.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAA21BMVEUAAAAAAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8BAf4CAv0DA/wdHeIeHuEfH+AgIN8hId4lJdomJtknJ9g+PsE/P8BAQL9yco10dIt1dYp3d4h4eIeVlWqWlmmXl2iYmGeZmWabm2Tn5xjo6Bfp6Rb39wj4+Af//wA2M9hbAAAASXRSTlMAAQIJCgsMJSYnKD4/QGRlZmhpamtsbautrrCxuru8y8zN5ebn6Pn6+///////////////////////////////////////////LsUNcQAAAS9JREFUOI29k21XgkAQhVcFytdSMqMETU26UVqGmpaiFbL//xc1cAhhwVNf6n5i5z67M2dmYOyfJZUqlVLhkKucG7cgmUZTybDz6g0iDeq51PUr37Ds2cy2/C9NeES5puDjxuUk1xnToZsg8pfA3avHQ3lLIi7iWRrkv/OYtkScxBIMgDee0ALoyxHQBJ68JLCjOtQIMIANF7QG9G9fNnHvisCHBVMKgSJgiz7nE+AoBKrAPA3MgepvgR9TSCasrCKH0eB1wBGBFdCO+nAGjMVGPcQb5bd6mQRegN6+1axOs9nGfYcCtfi4NQosdtH7dB+txFIpXQqN1p9B/asRHToyS0jRgpV7nk4nwcq1BJ+x3Gl/v7S9Wmpp/aGquum7w3ZDyrADFYrl8vHBH+ev9AUASW1dmU4h4wAAAABJRU5ErkJggg==" document.getElementsByTagName('head')[0].appendChild(link); </script>