-
Notifications
You must be signed in to change notification settings - Fork 34
colRowWeightedMeans_subset
matrixStats: Benchmark report
This report benchmark the performance of colWeightedMeans() and rowWeightedMeans() on subsetted computation.
> 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 = "double")
> X <- data[["10x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3220830 172.1 5709258 305.0 5709258 305.0
Vcells 6731746 51.4 22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMeans_X_w_S = colWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `colWeightedMeans(X, w, rows, cols)` = colWeightedMeans(X, w = w, rows = rows, cols = cols, na.rm = FALSE),
+ `colWeightedMeans(X[rows, cols], w[rows])` = colWeightedMeans(X[rows, cols], w = w[rows], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3219991 172.0 5709258 305.0 5709258 305.0
Vcells 6729258 51.4 22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMeans_X_w_S = rowWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `rowWeightedMeans(X, w, cols, rows)` = rowWeightedMeans(X, w = w, rows = cols, cols = rows, na.rm = FALSE),
+ `rowWeightedMeans(X[cols, rows], w[rows])` = rowWeightedMeans(X[cols, rows], w = w[rows], na.rm = FALSE),
+ unit = "ms")
Table: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 0.008422 | 0.0088190 | 0.0090774 | 0.0090070 | 0.0092395 | 0.016219 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 0.009737 | 0.0102495 | 0.0104549 | 0.0104245 | 0.0105650 | 0.014009 |
2 | colWeightedMeans(X, w, rows, cols) | 0.010534 | 0.0111485 | 0.0145679 | 0.0113280 | 0.0115600 | 0.325739 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.0000000 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 1.156139 | 1.162207 | 1.151757 | 1.157378 | 1.14346 | 0.8637401 |
2 | colWeightedMeans(X, w, rows, cols) | 1.250772 | 1.264146 | 1.604858 | 1.257688 | 1.25115 | 20.0837906 |
Table: Benchmarking of rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on 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 | rowWeightedMeans_X_w_S | 0.010462 | 0.0106835 | 0.0109957 | 0.0108735 | 0.011067 | 0.015903 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 0.011303 | 0.0119175 | 0.0123037 | 0.0121050 | 0.012298 | 0.021273 |
2 | rowWeightedMeans(X, w, cols, rows) | 0.012672 | 0.0129740 | 0.0166216 | 0.0131220 | 0.013385 | 0.345761 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 1.080386 | 1.115505 | 1.118956 | 1.113257 | 1.111232 | 1.337672 |
2 | rowWeightedMeans(X, w, cols, rows) | 1.211241 | 1.214396 | 1.511647 | 1.206787 | 1.209451 | 21.741873 |
Figure: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 10x10 data as well as rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 8.422 | 8.8190 | 9.07736 | 9.0070 | 9.2395 | 16.219 |
2 | rowWeightedMeans_X_w_S | 10.462 | 10.6835 | 10.99570 | 10.8735 | 11.0670 | 15.903 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowWeightedMeans_X_w_S | 1.242223 | 1.211418 | 1.211332 | 1.207228 | 1.197792 | 0.9805167 |
Figure: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3218973 172.0 5709258 305.0 5709258 305.0
Vcells 6399938 48.9 22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMeans_X_w_S = colWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `colWeightedMeans(X, w, rows, cols)` = colWeightedMeans(X, w = w, rows = rows, cols = cols, na.rm = FALSE),
+ `colWeightedMeans(X[rows, cols], w[rows])` = colWeightedMeans(X[rows, cols], w = w[rows], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3218964 172 5709258 305.0 5709258 305.0
Vcells 6410016 49 22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMeans_X_w_S = rowWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `rowWeightedMeans(X, w, cols, rows)` = rowWeightedMeans(X, w = w, rows = cols, cols = rows, na.rm = FALSE),
+ `rowWeightedMeans(X[cols, rows], w[rows])` = rowWeightedMeans(X[cols, rows], w = w[rows], na.rm = FALSE),
+ unit = "ms")
Table: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 0.018505 | 0.0191635 | 0.0200976 | 0.0197605 | 0.0206115 | 0.026853 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 0.034474 | 0.0357510 | 0.0375220 | 0.0362285 | 0.0375605 | 0.073949 |
2 | colWeightedMeans(X, w, rows, cols) | 0.042417 | 0.0432050 | 0.0457495 | 0.0438460 | 0.0459230 | 0.113261 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 1.862956 | 1.865578 | 1.866988 | 1.833380 | 1.822308 | 2.753845 |
2 | colWeightedMeans(X, w, rows, cols) | 2.292191 | 2.254546 | 2.276367 | 2.218871 | 2.228028 | 4.217816 |
Table: Benchmarking of rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on 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 | rowWeightedMeans_X_w_S | 0.055723 | 0.056827 | 0.0575488 | 0.0572280 | 0.0579205 | 0.067981 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 0.065264 | 0.065902 | 0.0668488 | 0.0664445 | 0.0673160 | 0.076393 |
2 | rowWeightedMeans(X, w, cols, rows) | 0.072875 | 0.073695 | 0.0756670 | 0.0745210 | 0.0757430 | 0.138304 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 1.171222 | 1.159695 | 1.161601 | 1.161049 | 1.162214 | 1.123741 |
2 | rowWeightedMeans(X, w, cols, rows) | 1.307808 | 1.296831 | 1.314832 | 1.302177 | 1.307706 | 2.034451 |
Figure: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 100x100 data as well as rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 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 | colWeightedMeans_X_w_S | 18.505 | 19.1635 | 20.09761 | 19.7605 | 20.6115 | 26.853 |
2 | rowWeightedMeans_X_w_S | 55.723 | 56.8270 | 57.54882 | 57.2280 | 57.9205 | 67.981 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowWeightedMeans_X_w_S | 3.01124 | 2.965377 | 2.863466 | 2.896081 | 2.810106 | 2.531598 |
Figure: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x10"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3219730 172.0 5709258 305.0 5709258 305.0
Vcells 6405864 48.9 22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMeans_X_w_S = colWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `colWeightedMeans(X, w, rows, cols)` = colWeightedMeans(X, w = w, rows = rows, cols = cols, na.rm = FALSE),
+ `colWeightedMeans(X[rows, cols], w[rows])` = colWeightedMeans(X[rows, cols], w = w[rows], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3219721 172 5709258 305.0 5709258 305.0
Vcells 6415942 49 22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMeans_X_w_S = rowWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `rowWeightedMeans(X, w, cols, rows)` = rowWeightedMeans(X, w = w, rows = cols, cols = rows, na.rm = FALSE),
+ `rowWeightedMeans(X[cols, rows], w[rows])` = rowWeightedMeans(X[cols, rows], w = w[rows], na.rm = FALSE),
+ unit = "ms")
Table: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 0.026795 | 0.0274550 | 0.0287832 | 0.0277690 | 0.029024 | 0.058835 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 0.044465 | 0.0453660 | 0.0467978 | 0.0460920 | 0.047612 | 0.060079 |
2 | colWeightedMeans(X, w, rows, cols) | 0.054934 | 0.0558125 | 0.0576411 | 0.0563185 | 0.057492 | 0.137369 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 1.659451 | 1.652377 | 1.625871 | 1.659836 | 1.640435 | 1.021144 |
2 | colWeightedMeans(X, w, rows, cols) | 2.050159 | 2.032872 | 2.002590 | 2.028107 | 1.980843 | 2.334818 |
Table: Benchmarking of rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on 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 | rowWeightedMeans_X_w_S | 0.065006 | 0.0658005 | 0.0664799 | 0.066194 | 0.0666275 | 0.071336 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 0.077246 | 0.0780405 | 0.0795255 | 0.078481 | 0.0792495 | 0.150825 |
2 | rowWeightedMeans(X, w, cols, rows) | 0.089107 | 0.0902450 | 0.0916613 | 0.090808 | 0.0916245 | 0.121058 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowWeightedMeans_X_w_S | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 1.18829 | 1.186017 | 1.196234 | 1.185621 | 1.189441 | 2.114290 |
2 | rowWeightedMeans(X, w, cols, rows) | 1.37075 | 1.371494 | 1.378782 | 1.371846 | 1.375175 | 1.697011 |
Figure: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 1000x10 data as well as rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 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 | colWeightedMeans_X_w_S | 26.795 | 27.4550 | 28.78325 | 27.769 | 29.0240 | 58.835 |
2 | rowWeightedMeans_X_w_S | 65.006 | 65.8005 | 66.47990 | 66.194 | 66.6275 | 71.336 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.0000 | 1.000000 |
2 | rowWeightedMeans_X_w_S | 2.42605 | 2.396667 | 2.309673 | 2.383737 | 2.2956 | 1.212476 |
Figure: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["10x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3219930 172.0 5709258 305.0 5709258 305.0
Vcells 6405137 48.9 22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMeans_X_w_S = colWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `colWeightedMeans(X, w, rows, cols)` = colWeightedMeans(X, w = w, rows = rows, cols = cols, na.rm = FALSE),
+ `colWeightedMeans(X[rows, cols], w[rows])` = colWeightedMeans(X[rows, cols], w = w[rows], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3219921 172 5709258 305.0 5709258 305.0
Vcells 6415215 49 22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMeans_X_w_S = rowWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `rowWeightedMeans(X, w, cols, rows)` = rowWeightedMeans(X, w = w, rows = cols, cols = rows, na.rm = FALSE),
+ `rowWeightedMeans(X[cols, rows], w[rows])` = rowWeightedMeans(X[cols, rows], w = w[rows], na.rm = FALSE),
+ unit = "ms")
Table: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 0.018081 | 0.0188180 | 0.0199830 | 0.0191135 | 0.019512 | 0.074175 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 0.028089 | 0.0289945 | 0.0294583 | 0.0292890 | 0.029721 | 0.032773 |
2 | colWeightedMeans(X, w, rows, cols) | 0.036647 | 0.0375030 | 0.0386619 | 0.0380405 | 0.038872 | 0.063118 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 1.553509 | 1.540785 | 1.474167 | 1.532372 | 1.523216 | 0.4418335 |
2 | colWeightedMeans(X, w, rows, cols) | 2.026824 | 1.992932 | 1.934739 | 1.990242 | 1.992210 | 0.8509336 |
Table: Benchmarking of rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on 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 | rowWeightedMeans_X_w_S | 0.054120 | 0.0549015 | 0.0555479 | 0.0551930 | 0.0555910 | 0.063898 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 0.063296 | 0.0639285 | 0.0655693 | 0.0642665 | 0.0646320 | 0.154854 |
2 | rowWeightedMeans(X, w, cols, rows) | 0.070700 | 0.0717700 | 0.0726398 | 0.0721455 | 0.0725115 | 0.101257 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 1.169549 | 1.164422 | 1.180410 | 1.164396 | 1.162634 | 2.423456 |
2 | rowWeightedMeans(X, w, cols, rows) | 1.306356 | 1.307250 | 1.307696 | 1.307149 | 1.304375 | 1.584666 |
Figure: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 10x1000 data as well as rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 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 | colWeightedMeans_X_w_S | 18.081 | 18.8180 | 19.98299 | 19.1135 | 19.512 | 74.175 |
2 | rowWeightedMeans_X_w_S | 54.120 | 54.9015 | 55.54790 | 55.1930 | 55.591 | 63.898 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 |
2 | rowWeightedMeans_X_w_S | 2.993197 | 2.917499 | 2.779759 | 2.887645 | 2.849067 | 0.8614493 |
Figure: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["100x1000"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3220138 172.0 5709258 305.0 5709258 305.0
Vcells 6450084 49.3 22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMeans_X_w_S = colWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `colWeightedMeans(X, w, rows, cols)` = colWeightedMeans(X, w = w, rows = rows, cols = cols, na.rm = FALSE),
+ `colWeightedMeans(X[rows, cols], w[rows])` = colWeightedMeans(X[rows, cols], w = w[rows], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3220129 172 5709258 305.0 5709258 305.0
Vcells 6550162 50 22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMeans_X_w_S = rowWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `rowWeightedMeans(X, w, cols, rows)` = rowWeightedMeans(X, w = w, rows = cols, cols = rows, na.rm = FALSE),
+ `rowWeightedMeans(X[cols, rows], w[rows])` = rowWeightedMeans(X[cols, rows], w = w[rows], na.rm = FALSE),
+ unit = "ms")
Table: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 0.086715 | 0.0936375 | 0.1324199 | 0.1033760 | 0.1913845 | 0.216416 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 0.236394 | 0.2543960 | 0.3355398 | 0.2859300 | 0.4473855 | 0.478072 |
2 | colWeightedMeans(X, w, rows, cols) | 0.296554 | 0.3096775 | 0.4974049 | 0.3571465 | 0.6114485 | 6.401086 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 2.726103 | 2.716817 | 2.533907 | 2.765922 | 2.337627 | 2.209042 |
2 | colWeightedMeans(X, w, rows, cols) | 3.419870 | 3.307195 | 3.756269 | 3.454830 | 3.194869 | 29.577693 |
Table: Benchmarking of rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on 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 | rowWeightedMeans_X_w_S | 0.448142 | 0.4494210 | 0.4642071 | 0.4520655 | 0.4597655 | 0.585779 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 0.517342 | 0.5194130 | 0.5953113 | 0.5225275 | 0.5274235 | 6.720449 |
2 | rowWeightedMeans(X, w, cols, rows) | 0.586399 | 0.5900345 | 0.6102561 | 0.5932900 | 0.6014325 | 0.749185 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 1.154415 | 1.155738 | 1.282426 | 1.155867 | 1.147158 | 11.472670 |
2 | rowWeightedMeans(X, w, cols, rows) | 1.308512 | 1.312877 | 1.314620 | 1.312398 | 1.308129 | 1.278955 |
Figure: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 100x1000 data as well as rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 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 | colWeightedMeans_X_w_S | 86.715 | 93.6375 | 132.4199 | 103.3760 | 191.3845 | 216.416 |
2 | rowWeightedMeans_X_w_S | 448.142 | 449.4210 | 464.2071 | 452.0655 | 459.7655 | 585.779 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowWeightedMeans_X_w_S | 5.167987 | 4.799583 | 3.505568 | 4.373022 | 2.402313 | 2.706727 |
Figure: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.
> X <- data[["1000x100"]]
> rows <- sample.int(nrow(X), size = nrow(X) * 0.7)
> cols <- sample.int(ncol(X), size = ncol(X) * 0.7)
> X_S <- X[rows, cols]
> w <- runif(nrow(X))
> w_S <- w[rows]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3220345 172.0 5709258 305.0 5709258 305.0
Vcells 6452397 49.3 22345847 170.5 56666022 432.4
> colStats <- microbenchmark(colWeightedMeans_X_w_S = colWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `colWeightedMeans(X, w, rows, cols)` = colWeightedMeans(X, w = w, rows = rows, cols = cols, na.rm = FALSE),
+ `colWeightedMeans(X[rows, cols], w[rows])` = colWeightedMeans(X[rows, cols], w = w[rows], na.rm = FALSE),
+ unit = "ms")
> X <- t(X)
> X_S <- t(X_S)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3220336 172 5709258 305.0 5709258 305.0
Vcells 6552475 50 22345847 170.5 56666022 432.4
> rowStats <- microbenchmark(rowWeightedMeans_X_w_S = rowWeightedMeans(X_S, w = w_S, na.rm = FALSE),
+ `rowWeightedMeans(X, w, cols, rows)` = rowWeightedMeans(X, w = w, rows = cols, cols = rows, na.rm = FALSE),
+ `rowWeightedMeans(X[cols, rows], w[rows])` = rowWeightedMeans(X[cols, rows], w = w[rows], na.rm = FALSE),
+ unit = "ms")
Table: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 0.104403 | 0.1366315 | 0.1931331 | 0.2080620 | 0.219613 | 0.327439 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 0.176720 | 0.2192125 | 0.4169919 | 0.3766440 | 0.390549 | 9.763244 |
2 | colWeightedMeans(X, w, rows, cols) | 0.238867 | 0.3015410 | 0.4855723 | 0.5448855 | 0.564166 | 0.682642 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | colWeightedMeans(X[rows, cols], w[rows]) | 1.692672 | 1.604407 | 2.159091 | 1.810249 | 1.778351 | 29.816986 |
2 | colWeightedMeans(X, w, rows, cols) | 2.287932 | 2.206965 | 2.514185 | 2.618861 | 2.568910 | 2.084791 |
Table: Benchmarking of rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on 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 | rowWeightedMeans_X_w_S | 0.457238 | 0.4592535 | 0.4712499 | 0.4606355 | 0.4644000 | 0.597803 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 0.533144 | 0.5368280 | 0.5588002 | 0.5394435 | 0.5507575 | 0.745953 |
2 | rowWeightedMeans(X, w, cols, rows) | 0.598959 | 0.6122735 | 0.7004234 | 0.6154305 | 0.6302045 | 6.803909 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | rowWeightedMeans_X_w_S | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
3 | rowWeightedMeans(X[cols, rows], w[rows]) | 1.16601 | 1.168914 | 1.185783 | 1.171085 | 1.185955 | 1.247824 |
2 | rowWeightedMeans(X, w, cols, rows) | 1.30995 | 1.333193 | 1.486310 | 1.336047 | 1.357030 | 11.381524 |
Figure: Benchmarking of colWeightedMeans_X_w_S(), colWeightedMeans(X, w, rows, cols)() and colWeightedMeans(X[rows, cols], w[rows])() on 1000x100 data as well as rowWeightedMeans_X_w_S(), rowWeightedMeans(X, w, cols, rows)() and rowWeightedMeans(X[cols, rows], w[rows])() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.
Table: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 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 | colWeightedMeans_X_w_S | 104.403 | 136.6315 | 193.1331 | 208.0620 | 219.613 | 327.439 |
2 | rowWeightedMeans_X_w_S | 457.238 | 459.2535 | 471.2499 | 460.6355 | 464.400 | 597.803 |
expr | min | lq | mean | median | uq | max | |
---|---|---|---|---|---|---|---|
1 | colWeightedMeans_X_w_S | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
2 | rowWeightedMeans_X_w_S | 4.379549 | 3.361256 | 2.440027 | 2.213934 | 2.114629 | 1.825693 |
Figure: Benchmarking of colWeightedMeans_X_w_S() and rowWeightedMeans_X_w_S() on 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 12.21 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('colRowWeightedMeans_subset')
Copyright Dongcan Jiang. Last updated on 2019-09-10 20:55:21 (-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>