-
Notifications
You must be signed in to change notification settings - Fork 34
colRowMeans2
matrixStats: Benchmark report
This report benchmark the performance of colMeans2() and rowMeans2() against alternative methods.
- apply() + mean()
- .colMeans() and .rowMeans()
- colMeans() and rowMeans()
> 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"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139851 167.7 5709258 305.0 5709258 305.0
Vcells 6077827 46.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138984 167.7 5709258 305.0 5709258 305.0
Vcells 6075817 46.4 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | colMeans2 | 0.001118 | 0.0013945 | 0.0018182 | 0.0018415 | 0.0019805 | 0.011639 |
2 | .colMeans | 0.001602 | 0.0018650 | 0.0023100 | 0.0021000 | 0.0025185 | 0.014027 |
3 | colMeans | 0.003010 | 0.0032895 | 0.0040018 | 0.0039165 | 0.0043600 | 0.013600 |
4 | apply+mean | 0.044338 | 0.0458210 | 0.0477659 | 0.0463565 | 0.0470120 | 0.144426 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .colMeans | 1.432916 | 1.337397 | 1.270511 | 1.140375 | 1.271649 | 1.205172 |
3 | colMeans | 2.692308 | 2.358910 | 2.200975 | 2.126799 | 2.201464 | 1.168485 |
4 | apply+mean | 39.658318 | 32.858372 | 26.271116 | 25.173228 | 23.737440 | 12.408798 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.001100 | 0.0013460 | 0.0017564 | 0.0017395 | 0.0019180 | 0.010729 |
2 | .rowMeans | 0.002473 | 0.0026470 | 0.0029007 | 0.0028050 | 0.0029790 | 0.009608 |
3 | rowMeans | 0.003673 | 0.0039865 | 0.0046466 | 0.0045145 | 0.0047140 | 0.029878 |
4 | apply+mean | 0.044563 | 0.0455930 | 0.0469140 | 0.0459645 | 0.0464085 | 0.103257 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | .rowMeans | 2.248182 | 1.966568 | 1.651481 | 1.612532 | 1.553180 | 0.8955168 |
3 | rowMeans | 3.339091 | 2.961739 | 2.645451 | 2.595286 | 2.457768 | 2.7847889 |
4 | apply+mean | 40.511818 | 33.872957 | 26.709855 | 26.423972 | 24.196298 | 9.6241029 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on integer+10x10 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | rowMeans2 | 1.100 | 1.3460 | 1.75643 | 1.7395 | 1.9180 | 10.729 |
1 | colMeans2 | 1.118 | 1.3945 | 1.81819 | 1.8415 | 1.9805 | 11.639 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | colMeans2 | 1.016364 | 1.036033 | 1.035162 | 1.058637 | 1.032586 | 1.084817 |
Figure: Benchmarking of colMeans2() and rowMeans2() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3137564 167.6 5709258 305.0 5709258 305.0
Vcells 5692629 43.5 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3137555 167.6 5709258 305.0 5709258 305.0
Vcells 5697667 43.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.009152 | 0.0095320 | 0.0100594 | 0.0099955 | 0.0103290 | 0.015906 |
3 | colMeans | 0.010689 | 0.0113320 | 0.0119437 | 0.0118010 | 0.0123520 | 0.018471 |
1 | colMeans2 | 0.011058 | 0.0114345 | 0.0122556 | 0.0118535 | 0.0121290 | 0.044265 |
4 | apply+mean | 0.389271 | 0.3951415 | 0.4015145 | 0.3986820 | 0.4022945 | 0.509034 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colMeans | 1.167941 | 1.188838 | 1.187323 | 1.180631 | 1.195856 | 1.161260 |
1 | colMeans2 | 1.208260 | 1.199591 | 1.218332 | 1.185884 | 1.174267 | 2.782912 |
4 | apply+mean | 42.533982 | 41.454207 | 39.914514 | 39.886149 | 38.948059 | 32.002640 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.011204 | 0.0115515 | 0.0121952 | 0.0120125 | 0.0124430 | 0.021796 |
2 | .rowMeans | 0.038564 | 0.0389080 | 0.0393451 | 0.0391395 | 0.0394070 | 0.049944 |
3 | rowMeans | 0.040023 | 0.0404875 | 0.0411525 | 0.0411120 | 0.0414240 | 0.048529 |
4 | apply+mean | 0.387624 | 0.3917800 | 0.3984268 | 0.3944985 | 0.3990515 | 0.500580 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
2 | .rowMeans | 3.441985 | 3.368221 | 3.226285 | 3.258231 | 3.167002 | 2.29143 |
3 | rowMeans | 3.572206 | 3.504956 | 3.374493 | 3.422435 | 3.329101 | 2.22651 |
4 | apply+mean | 34.596930 | 33.915942 | 32.670873 | 32.840666 | 32.070361 | 22.96660 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on integer+100x100 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 11.058 | 11.4345 | 12.25564 | 11.8535 | 12.129 | 44.265 |
2 | rowMeans2 | 11.204 | 11.5515 | 12.19517 | 12.0125 | 12.443 | 21.796 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMeans2 | 1.013203 | 1.010232 | 0.9950659 | 1.013414 | 1.025888 | 0.4923981 |
Figure: Benchmarking of colMeans2() and rowMeans2() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138330 167.7 5709258 305.0 5709258 305.0
Vcells 5696415 43.5 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138321 167.7 5709258 305.0 5709258 305.0
Vcells 5701453 43.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.009389 | 0.0098325 | 0.0105085 | 0.0102025 | 0.0105670 | 0.037245 |
3 | colMeans | 0.010948 | 0.0113905 | 0.0123146 | 0.0120045 | 0.0125850 | 0.031726 |
1 | colMeans2 | 0.012227 | 0.0128430 | 0.0133656 | 0.0132430 | 0.0134815 | 0.028296 |
4 | apply+mean | 0.100870 | 0.1024890 | 0.1056013 | 0.1033105 | 0.1048780 | 0.173595 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
3 | colMeans | 1.166045 | 1.158454 | 1.171861 | 1.176623 | 1.190972 | 0.8518190 |
1 | colMeans2 | 1.302269 | 1.306178 | 1.271878 | 1.298015 | 1.275812 | 0.7597261 |
4 | apply+mean | 10.743423 | 10.423493 | 10.049095 | 10.125998 | 9.925050 | 4.6608941 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.012525 | 0.0130485 | 0.0135167 | 0.0134115 | 0.0136675 | 0.027150 |
4 | apply+mean | 0.100688 | 0.1023380 | 0.1049152 | 0.1029525 | 0.1045485 | 0.209029 |
2 | .rowMeans | 0.135357 | 0.1361160 | 0.1364440 | 0.1363250 | 0.1365440 | 0.140769 |
3 | rowMeans | 0.136966 | 0.1377290 | 0.1384011 | 0.1383265 | 0.1386560 | 0.146218 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
4 | apply+mean | 8.038962 | 7.842894 | 7.761877 | 7.676434 | 7.649424 | 7.699042 |
2 | .rowMeans | 10.806946 | 10.431544 | 10.094450 | 10.164784 | 9.990415 | 5.184862 |
3 | rowMeans | 10.935409 | 10.555160 | 10.239241 | 10.314022 | 10.144942 | 5.385562 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on integer+1000x10 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | colMeans2 | 12.227 | 12.8430 | 13.36558 | 13.2430 | 13.4815 | 28.296 |
2 | rowMeans2 | 12.525 | 13.0485 | 13.51673 | 13.4115 | 13.6675 | 27.150 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMeans2 | 1.024372 | 1.016001 | 1.011309 | 1.012724 | 1.013797 | 0.9594996 |
Figure: Benchmarking of colMeans2() and rowMeans2() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["10x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138552 167.7 5709258 305.0 5709258 305.0
Vcells 5697223 43.5 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138543 167.7 5709258 305.0 5709258 305.0
Vcells 5702261 43.6 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.009074 | 0.009620 | 0.0109615 | 0.0103155 | 0.011103 | 0.023892 |
1 | colMeans2 | 0.010614 | 0.011105 | 0.0127047 | 0.0119750 | 0.013109 | 0.026440 |
3 | colMeans | 0.010567 | 0.011371 | 0.0130535 | 0.0125615 | 0.013851 | 0.023245 |
4 | apply+mean | 3.208715 | 3.267930 | 3.4315273 | 3.3277545 | 3.455468 | 8.267523 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
1 | colMeans2 | 1.169716 | 1.154366 | 1.159031 | 1.160874 | 1.180672 | 1.1066466 |
3 | colMeans | 1.164536 | 1.182017 | 1.190846 | 1.217731 | 1.247501 | 0.9729198 |
4 | apply+mean | 353.616377 | 339.701715 | 313.052712 | 322.597499 | 311.219355 | 346.0372928 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.010936 | 0.0114295 | 0.0126284 | 0.012351 | 0.0133470 | 0.020203 |
2 | .rowMeans | 0.030953 | 0.0314140 | 0.0330664 | 0.031832 | 0.0331605 | 0.058767 |
3 | rowMeans | 0.032560 | 0.0330545 | 0.0351301 | 0.034382 | 0.0353905 | 0.052018 |
4 | apply+mean | 3.197030 | 3.2592550 | 3.4373507 | 3.341137 | 3.4499105 | 8.425955 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .rowMeans | 2.830377 | 2.748502 | 2.618415 | 2.577281 | 2.484491 | 2.908825 |
3 | rowMeans | 2.977323 | 2.892034 | 2.781836 | 2.783742 | 2.651570 | 2.574766 |
4 | apply+mean | 292.339978 | 285.161643 | 272.192098 | 270.515505 | 258.478347 | 417.064545 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on integer+10x1000 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 10.614 | 11.1050 | 12.70472 | 11.975 | 13.109 | 26.440 |
2 | rowMeans2 | 10.936 | 11.4295 | 12.62840 | 12.351 | 13.347 | 20.203 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMeans2 | 1.030337 | 1.029221 | 0.9939928 | 1.031399 | 1.018155 | 0.7641074 |
Figure: Benchmarking of colMeans2() and rowMeans2() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138772 167.7 5709258 305.0 5709258 305.0
Vcells 5697806 43.5 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138766 167.7 5709258 305.0 5709258 305.0
Vcells 5747849 43.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.074811 | 0.0755745 | 0.0785353 | 0.0770220 | 0.0788250 | 0.108906 |
3 | colMeans | 0.076820 | 0.0776875 | 0.0822842 | 0.0796755 | 0.0830435 | 0.135364 |
1 | colMeans2 | 0.099775 | 0.1002240 | 0.1053356 | 0.1023415 | 0.1066470 | 0.131193 |
4 | apply+mean | 3.770532 | 3.8167745 | 4.1021140 | 3.8867665 | 4.0373260 | 15.632112 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colMeans | 1.026854 | 1.027959 | 1.047736 | 1.034451 | 1.053517 | 1.242943 |
1 | colMeans2 | 1.333694 | 1.326162 | 1.341251 | 1.328731 | 1.352959 | 1.204644 |
4 | apply+mean | 50.400770 | 50.503470 | 52.232741 | 50.463069 | 51.218852 | 143.537656 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.105809 | 0.1063705 | 0.1106376 | 0.1072835 | 0.1092985 | 0.204664 |
2 | .rowMeans | 0.272818 | 0.2733865 | 0.2794856 | 0.2739900 | 0.2760480 | 0.367536 |
3 | rowMeans | 0.274481 | 0.2752600 | 0.2806756 | 0.2763950 | 0.2789175 | 0.347585 |
4 | apply+mean | 3.788474 | 3.8303300 | 4.0666559 | 3.8958810 | 4.0174210 | 15.718836 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .rowMeans | 2.578401 | 2.570135 | 2.526135 | 2.553888 | 2.525634 | 1.795802 |
3 | rowMeans | 2.594118 | 2.587747 | 2.536891 | 2.576305 | 2.551888 | 1.698320 |
4 | apply+mean | 35.804837 | 36.009326 | 36.756538 | 36.313888 | 36.756415 | 76.803131 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on integer+100x1000 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 99.775 | 100.2240 | 105.3356 | 102.3415 | 106.6470 | 131.193 |
2 | rowMeans2 | 105.809 | 106.3705 | 110.6376 | 107.2835 | 109.2985 | 204.664 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowMeans2 | 1.060476 | 1.061328 | 1.050335 | 1.048289 | 1.024862 | 1.560022 |
Figure: Benchmarking of colMeans2() and rowMeans2() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139005 167.7 5709258 305.0 5709258 305.0
Vcells 5698593 43.5 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3138999 167.7 5709258 305.0 5709258 305.0
Vcells 5748636 43.9 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on integer+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.079366 | 0.0796445 | 0.0803061 | 0.0800025 | 0.0803930 | 0.085562 |
3 | colMeans | 0.081143 | 0.0817155 | 0.0829258 | 0.0823115 | 0.0829675 | 0.129585 |
1 | colMeans2 | 0.105009 | 0.1053790 | 0.1062905 | 0.1058115 | 0.1062135 | 0.124981 |
4 | apply+mean | 0.838260 | 0.8452160 | 0.8647765 | 0.8540085 | 0.8741790 | 1.017310 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colMeans | 1.022390 | 1.026003 | 1.032622 | 1.028862 | 1.032024 | 1.514516 |
1 | colMeans2 | 1.323098 | 1.323117 | 1.323566 | 1.322602 | 1.321179 | 1.460707 |
4 | apply+mean | 10.561953 | 10.612359 | 10.768500 | 10.674773 | 10.873820 | 11.889741 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.114807 | 0.1166280 | 0.1211237 | 0.1175665 | 0.1195020 | 0.219929 |
2 | .rowMeans | 0.371756 | 0.3728350 | 0.3784171 | 0.3732835 | 0.3743715 | 0.456133 |
3 | rowMeans | 0.373874 | 0.3746180 | 0.3790754 | 0.3753410 | 0.3780370 | 0.460845 |
4 | apply+mean | 0.852882 | 0.8707085 | 0.9019386 | 0.8792360 | 0.8988245 | 1.298366 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .rowMeans | 3.238095 | 3.196788 | 3.124220 | 3.175084 | 3.132763 | 2.074001 |
3 | rowMeans | 3.256544 | 3.212076 | 3.129655 | 3.192585 | 3.163437 | 2.095426 |
4 | apply+mean | 7.428833 | 7.465690 | 7.446426 | 7.478627 | 7.521418 | 5.903569 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on integer+1000x100 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | colMeans2 | 105.009 | 105.379 | 106.2905 | 105.8115 | 106.2135 | 124.981 |
2 | rowMeans2 | 114.807 | 116.628 | 121.1237 | 117.5665 | 119.5020 | 219.929 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowMeans2 | 1.093306 | 1.106748 | 1.139554 | 1.111094 | 1.125111 | 1.759699 |
Figure: Benchmarking of colMeans2() and rowMeans2() 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"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139245 167.7 5709258 305.0 5709258 305.0
Vcells 5814528 44.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139227 167.7 5709258 305.0 5709258 305.0
Vcells 5814651 44.4 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | colMeans2 | 0.001137 | 0.0014075 | 0.0018672 | 0.0018675 | 0.002051 | 0.012019 |
2 | .colMeans | 0.001644 | 0.0018460 | 0.0022731 | 0.0020850 | 0.002520 | 0.011391 |
3 | colMeans | 0.002991 | 0.0034025 | 0.0039936 | 0.0038965 | 0.004390 | 0.011282 |
4 | apply+mean | 0.045506 | 0.0463995 | 0.0481880 | 0.0470175 | 0.047545 | 0.145097 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | .colMeans | 1.445910 | 1.311545 | 1.217387 | 1.116466 | 1.228669 | 0.9477494 |
3 | colMeans | 2.630607 | 2.417407 | 2.138835 | 2.086479 | 2.140419 | 0.9386804 |
4 | apply+mean | 40.022867 | 32.965897 | 25.807903 | 25.176707 | 23.181375 | 12.0723022 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .rowMeans | 0.001270 | 0.0014695 | 0.0017708 | 0.0016930 | 0.0019405 | 0.005853 |
1 | rowMeans2 | 0.001105 | 0.0013700 | 0.0017901 | 0.0017550 | 0.0019500 | 0.010126 |
3 | rowMeans | 0.002554 | 0.0028565 | 0.0035454 | 0.0033785 | 0.0037425 | 0.022294 |
4 | apply+mean | 0.044823 | 0.0460120 | 0.0478368 | 0.0464970 | 0.0470385 | 0.100305 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .rowMeans | 1.0000000 | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | rowMeans2 | 0.8700787 | 0.9322899 | 1.010899 | 1.036621 | 1.004896 | 1.730053 |
3 | rowMeans | 2.0110236 | 1.9438585 | 2.002163 | 1.995570 | 1.928627 | 3.808987 |
4 | apply+mean | 35.2937008 | 31.3113304 | 27.014683 | 27.464265 | 24.240402 | 17.137366 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+10x10 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | rowMeans2 | 1.105 | 1.3700 | 1.79007 | 1.7550 | 1.950 | 10.126 |
1 | colMeans2 | 1.137 | 1.4075 | 1.86718 | 1.8675 | 2.051 | 12.019 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
1 | colMeans2 | 1.028959 | 1.027372 | 1.043076 | 1.064103 | 1.051795 | 1.186945 |
Figure: Benchmarking of colMeans2() and rowMeans2() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139462 167.7 5709258 305.0 5709258 305.0
Vcells 5815557 44.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139453 167.7 5709258 305.0 5709258 305.0
Vcells 5825595 44.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.008221 | 0.0087925 | 0.0096838 | 0.0092225 | 0.0096805 | 0.019484 |
3 | colMeans | 0.009916 | 0.0105470 | 0.0118815 | 0.0112720 | 0.0117985 | 0.036548 |
1 | colMeans2 | 0.011310 | 0.0116740 | 0.0129054 | 0.0122155 | 0.0125745 | 0.046964 |
4 | apply+mean | 0.443032 | 0.4478055 | 0.4671414 | 0.4521345 | 0.4629810 | 0.650094 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colMeans | 1.206179 | 1.199545 | 1.226943 | 1.222228 | 1.218790 | 1.875795 |
1 | colMeans2 | 1.375745 | 1.327722 | 1.332675 | 1.324532 | 1.298952 | 2.410388 |
4 | apply+mean | 53.890281 | 50.930395 | 48.239418 | 49.025156 | 47.826145 | 33.365531 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.011374 | 0.0117905 | 0.0123781 | 0.0122205 | 0.0126775 | 0.024969 |
2 | .rowMeans | 0.018457 | 0.0203275 | 0.0207877 | 0.0204935 | 0.0206905 | 0.043692 |
3 | rowMeans | 0.021277 | 0.0217830 | 0.0223839 | 0.0223900 | 0.0227155 | 0.030016 |
4 | apply+mean | 0.404403 | 0.4088945 | 0.4151887 | 0.4106470 | 0.4145620 | 0.532848 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .rowMeans | 1.622736 | 1.724058 | 1.679394 | 1.676977 | 1.632065 | 1.749850 |
3 | rowMeans | 1.870670 | 1.847504 | 1.808346 | 1.832167 | 1.791797 | 1.202131 |
4 | apply+mean | 35.555038 | 34.679997 | 33.542230 | 33.603126 | 32.700611 | 21.340382 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+100x100 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | colMeans2 | 11.310 | 11.6740 | 12.90537 | 12.2155 | 12.5745 | 46.964 |
2 | rowMeans2 | 11.374 | 11.7905 | 12.37809 | 12.2205 | 12.6775 | 24.969 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMeans2 | 1.005659 | 1.009979 | 0.9591426 | 1.000409 | 1.008191 | 0.5316626 |
Figure: Benchmarking of colMeans2() and rowMeans2() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139688 167.7 5709258 305.0 5709258 305.0
Vcells 5816683 44.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139679 167.7 5709258 305.0 5709258 305.0
Vcells 5826721 44.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.009459 | 0.0097845 | 0.0102891 | 0.010161 | 0.0104700 | 0.024951 |
3 | colMeans | 0.010823 | 0.0114160 | 0.0121760 | 0.011978 | 0.0125580 | 0.025641 |
1 | colMeans2 | 0.012415 | 0.0129345 | 0.0134168 | 0.013192 | 0.0135985 | 0.025389 |
4 | apply+mean | 0.152337 | 0.1540075 | 0.1570167 | 0.155667 | 0.1576625 | 0.216901 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colMeans | 1.144201 | 1.166743 | 1.183383 | 1.178821 | 1.199427 | 1.027654 |
1 | colMeans2 | 1.312507 | 1.321938 | 1.303984 | 1.298297 | 1.298806 | 1.017554 |
4 | apply+mean | 16.104979 | 15.739946 | 15.260493 | 15.320047 | 15.058500 | 8.693078 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.012531 | 0.0130100 | 0.0135245 | 0.0134345 | 0.0137750 | 0.021325 |
2 | .rowMeans | 0.020336 | 0.0205390 | 0.0208271 | 0.0207940 | 0.0209900 | 0.025154 |
3 | rowMeans | 0.021891 | 0.0222575 | 0.0228277 | 0.0227350 | 0.0230475 | 0.029208 |
4 | apply+mean | 0.110166 | 0.1129025 | 0.1155217 | 0.1139625 | 0.1153240 | 0.196645 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .rowMeans | 1.622855 | 1.578709 | 1.539953 | 1.547806 | 1.523775 | 1.179555 |
3 | rowMeans | 1.746948 | 1.710799 | 1.687874 | 1.692285 | 1.673140 | 1.369660 |
4 | apply+mean | 8.791477 | 8.678132 | 8.541647 | 8.482824 | 8.371978 | 9.221336 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+1000x10 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | colMeans2 | 12.415 | 12.9345 | 13.41682 | 13.1920 | 13.5985 | 25.389 |
2 | rowMeans2 | 12.531 | 13.0100 | 13.52452 | 13.4345 | 13.7750 | 21.325 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMeans2 | 1.009343 | 1.005837 | 1.008027 | 1.018382 | 1.012979 | 0.8399307 |
Figure: Benchmarking of colMeans2() and rowMeans2() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["10x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139910 167.7 5709258 305.0 5709258 305.0
Vcells 5816830 44.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3139901 167.7 5709258 305.0 5709258 305.0
Vcells 5826868 44.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.009119 | 0.0096180 | 0.0108982 | 0.0103445 | 0.0111785 | 0.020629 |
3 | colMeans | 0.010592 | 0.0115365 | 0.0132383 | 0.0128655 | 0.0143210 | 0.023064 |
1 | colMeans2 | 0.012080 | 0.0125470 | 0.0143993 | 0.0133060 | 0.0143800 | 0.065356 |
4 | apply+mean | 3.233188 | 3.3239640 | 3.5124924 | 3.4266600 | 3.5333660 | 8.546768 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colMeans | 1.161531 | 1.199470 | 1.214727 | 1.243704 | 1.281120 | 1.118038 |
1 | colMeans2 | 1.324707 | 1.304533 | 1.321260 | 1.286287 | 1.286398 | 3.168161 |
4 | apply+mean | 354.555105 | 345.598253 | 322.300532 | 331.254290 | 316.085879 | 414.308401 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.012227 | 0.0127810 | 0.0146545 | 0.0137915 | 0.0147080 | 0.062302 |
2 | .rowMeans | 0.019566 | 0.0202355 | 0.0215739 | 0.0209840 | 0.0225900 | 0.026842 |
3 | rowMeans | 0.021130 | 0.0218835 | 0.0246065 | 0.0231680 | 0.0245015 | 0.077906 |
4 | apply+mean | 3.246822 | 3.3370775 | 3.5229248 | 3.4122410 | 3.5453170 | 8.447450 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | .rowMeans | 1.600229 | 1.583249 | 1.472164 | 1.521517 | 1.535899 | 0.4308369 |
3 | rowMeans | 1.728143 | 1.712190 | 1.679107 | 1.679875 | 1.665862 | 1.2504574 |
4 | apply+mean | 265.545269 | 261.096745 | 240.398345 | 247.416235 | 241.046845 | 135.5887451 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+10x1000 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() on double+10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 12.080 | 12.547 | 14.39934 | 13.3060 | 14.380 | 65.356 |
2 | rowMeans2 | 12.227 | 12.781 | 14.65453 | 13.7915 | 14.708 | 62.302 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMeans2 | 1.012169 | 1.01865 | 1.017722 | 1.036487 | 1.022809 | 0.9532713 |
Figure: Benchmarking of colMeans2() and rowMeans2() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3140130 167.8 5709258 305.0 5709258 305.0
Vcells 5818143 44.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3140124 167.8 5709258 305.0 5709258 305.0
Vcells 5918186 45.2 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() 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 | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.064567 | 0.065199 | 0.0720234 | 0.0684560 | 0.0778060 | 0.114816 |
3 | colMeans | 0.066360 | 0.067253 | 0.0743774 | 0.0703435 | 0.0786795 | 0.161419 |
1 | colMeans2 | 0.100799 | 0.101367 | 0.1175601 | 0.1050505 | 0.1103315 | 0.726208 |
4 | apply+mean | 4.343545 | 4.405486 | 4.6693956 | 4.4575465 | 4.5427805 | 18.057693 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colMeans | 1.027770 | 1.031504 | 1.032684 | 1.027572 | 1.011227 | 1.405893 |
1 | colMeans2 | 1.561154 | 1.554732 | 1.632250 | 1.534570 | 1.418033 | 6.324972 |
4 | apply+mean | 67.271904 | 67.569840 | 64.831691 | 65.115498 | 58.385992 | 157.275058 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.107488 | 0.1080635 | 0.1176995 | 0.1089730 | 0.117304 | 0.241564 |
2 | .rowMeans | 0.180992 | 0.1825000 | 0.1893512 | 0.1835685 | 0.185773 | 0.251952 |
3 | rowMeans | 0.180206 | 0.1834630 | 0.1892023 | 0.1851485 | 0.188669 | 0.246761 |
4 | apply+mean | 3.915669 | 4.0004425 | 4.3035005 | 4.0729265 | 4.219132 | 17.113837 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .rowMeans | 1.683834 | 1.688822 | 1.608767 | 1.684532 | 1.583689 | 1.043003 |
3 | rowMeans | 1.676522 | 1.697733 | 1.607502 | 1.699031 | 1.608377 | 1.021514 |
4 | apply+mean | 36.428894 | 37.019368 | 36.563443 | 37.375556 | 35.967508 | 70.845975 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+100x1000 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | colMeans2 | 100.799 | 101.3670 | 117.5601 | 105.0505 | 110.3315 | 726.208 |
2 | rowMeans2 | 107.488 | 108.0635 | 117.6995 | 108.9730 | 117.3040 | 241.564 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowMeans2 | 1.06636 | 1.066062 | 1.001186 | 1.037339 | 1.063196 | 0.3326375 |
Figure: Benchmarking of colMeans2() and rowMeans2() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3140363 167.8 5709258 305.0 5709258 305.0
Vcells 5818301 44.4 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMeans2 = colMeans2(X, na.rm = FALSE), .colMeans = .colMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), colMeans = colMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 2L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3140357 167.8 5709258 305.0 5709258 305.0
Vcells 5918344 45.2 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMeans2 = rowMeans2(X, na.rm = FALSE), .rowMeans = .rowMeans(X, m = nrow(X),
+ n = ncol(X), na.rm = FALSE), rowMeans = rowMeans(X, na.rm = FALSE), `apply+mean` = apply(X, MARGIN = 1L,
+ FUN = mean, na.rm = FALSE), unit = "ms")
Table: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 0.077399 | 0.0777785 | 0.0811696 | 0.0784920 | 0.0821365 | 0.117364 |
3 | colMeans | 0.079115 | 0.0797960 | 0.0836713 | 0.0808430 | 0.0838830 | 0.115651 |
1 | colMeans2 | 0.104898 | 0.1053610 | 0.1102334 | 0.1063325 | 0.1139030 | 0.133721 |
4 | apply+mean | 0.938313 | 0.9515165 | 1.0568774 | 0.9737810 | 1.0373125 | 6.995496 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
2 | .colMeans | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
3 | colMeans | 1.022171 | 1.025939 | 1.030821 | 1.029952 | 1.021263 | 0.9854044 |
1 | colMeans2 | 1.355289 | 1.354629 | 1.358062 | 1.354692 | 1.386753 | 1.1393698 |
4 | apply+mean | 12.123064 | 12.233670 | 13.020611 | 12.406118 | 12.629130 | 59.6051259 |
Table: Benchmarking of rowMeans2(), .rowMeans(), rowMeans() and apply+mean() 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 | rowMeans2 | 0.107895 | 0.1088235 | 0.1138603 | 0.1095450 | 0.1119620 | 0.206995 |
2 | .rowMeans | 0.187725 | 0.1883625 | 0.1950287 | 0.1887395 | 0.1905115 | 0.328856 |
3 | rowMeans | 0.189587 | 0.1902130 | 0.1967597 | 0.1910290 | 0.1935570 | 0.320987 |
4 | apply+mean | 0.965276 | 0.9926910 | 1.1065505 | 1.0498105 | 1.0774335 | 6.995676 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | .rowMeans | 1.739886 | 1.730899 | 1.712878 | 1.722940 | 1.701573 | 1.588715 |
3 | rowMeans | 1.757143 | 1.747904 | 1.728080 | 1.743840 | 1.728774 | 1.550699 |
4 | apply+mean | 8.946439 | 9.122028 | 9.718496 | 9.583372 | 9.623207 | 33.796353 |
Figure: Benchmarking of colMeans2(), .colMeans(), colMeans() and apply+mean() on double+1000x100 data as well as rowMeans2(), .rowMeans(), rowMeans() and apply+mean() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colMeans2() and rowMeans2() 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 | colMeans2 | 104.898 | 105.3610 | 110.2334 | 106.3325 | 113.903 | 133.721 |
2 | rowMeans2 | 107.895 | 108.8235 | 113.8603 | 109.5450 | 111.962 | 206.995 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colMeans2 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 |
2 | rowMeans2 | 1.028571 | 1.032863 | 1.032902 | 1.030212 | 0.9829592 | 1.547962 |
Figure: Benchmarking of colMeans2() and rowMeans2() 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 28.82 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colMeans2')
Copyright Henrik Bengtsson. Last updated on 2019-09-10 20:44:05 (-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>