Skip to content

colRowRanks

hb edited this page Mar 3, 2015 · 2 revisions

matrixStats: Benchmark report


colRanks() and rowRanks() benchmarks

This report benchmark the performance of colRanks() and rowRanks() against alternative methods.

Alternative methods

  • apply() + rank()

Data type "integer"

Data

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

Results

10x10 integer matrix

> X <- data[["10x10"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805858 43.1    1442291  77.1  1442291  77.1
Vcells 12281216 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804682 43.0    1442291  77.1  1442291  77.1
Vcells 12277671 93.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.0219 0.0370 0.0634 0.0458 0.0835 0.4666
apply+rank 0.6086 0.6679 0.9051 0.9907 1.0781 1.6838
expr min lq mean median uq max
colRanks 1.00 1.00 1.00 1.00 1.00 1.000
apply+rank 27.73 18.07 14.27 21.63 12.91 3.609
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.0112 0.0192 0.0332 0.0258 0.0423 0.216
apply+rank 0.6194 0.9162 1.0319 0.9658 1.0848 2.591
expr min lq mean median uq max
rowRanks 1.00 1.0 1.00 1.00 1.00 1
apply+rank 55.48 47.6 31.09 37.45 25.62 12
Figure: Benchmarking of colRanks() and apply+rank() on integer+10x10 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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 rowRanks 11.16 19.25 33.19 25.79 42.35 216.0
1 colRanks 21.94 36.96 63.43 45.81 83.54 466.6
expr min lq mean median uq max
2 rowRanks 1.000 1.00 1.000 1.000 1.000 1.00
1 colRanks 1.965 1.92 1.911 1.776 1.973 2.16
Figure: Benchmarking of colRanks() and rowRanks() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 integer matrix

> X <- data[["100x100"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804858 43.0    1442291  77.1  1442291  77.1
Vcells 12278904 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804852 43.0    1442291  77.1  1442291  77.1
Vcells 12283947 93.8   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.4677 0.5372 0.6366 0.6071 0.6731 5.088
apply+rank 6.6997 8.6540 10.1316 10.2144 10.8734 19.869
expr min lq mean median uq max
colRanks 1.00 1.00 1.00 1.00 1.00 1.000
apply+rank 14.32 16.11 15.92 16.83 16.15 3.905
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.430 0.5565 0.5758 0.5713 0.6182 1.011
apply+rank 6.774 10.0188 10.6447 10.2421 10.6195 22.862
expr min lq mean median uq max
rowRanks 1.00 1 1.00 1.00 1.00 1.00
apply+rank 15.75 18 18.49 17.93 17.18 22.61
Figure: Benchmarking of colRanks() and apply+rank() on integer+100x100 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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 rowRanks 430.0 556.5 575.8 571.3 618.2 1011
1 colRanks 467.7 537.2 636.6 607.1 673.1 5088
expr min lq mean median uq max
2 rowRanks 1.000 1.0000 1.000 1.000 1.000 1.000
1 colRanks 1.088 0.9654 1.106 1.063 1.089 5.031
Figure: Benchmarking of colRanks() and rowRanks() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 integer matrix

> X <- data[["1000x10"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804893 43.0    1442291  77.1  1442291  77.1
Vcells 12278927 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804887 43.0    1442291  77.1  1442291  77.1
Vcells 12283970 93.8   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.5867 0.6458 0.6699 0.6581 0.7141 0.8808
apply+rank 2.1369 2.2239 2.5919 2.3563 2.9588 3.3664
expr min lq mean median uq max
colRanks 1.000 1.000 1.000 1.000 1.000 1.000
apply+rank 3.642 3.444 3.869 3.581 4.143 3.822
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.5613 0.6327 0.6648 0.6569 0.6679 1.409
apply+rank 2.2978 2.9965 3.2506 3.0893 3.1749 7.486
expr min lq mean median uq max
rowRanks 1.000 1.000 1.00 1.000 1.000 1.000
apply+rank 4.094 4.736 4.89 4.703 4.754 5.312
Figure: Benchmarking of colRanks() and apply+rank() on integer+1000x10 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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
2 rowRanks 561.3 632.7 664.8 656.9 667.9 1409.3
1 colRanks 586.7 645.8 669.9 658.1 714.1 880.8
expr min lq mean median uq max
2 rowRanks 1.000 1.000 1.000 1.000 1.000 1.000
1 colRanks 1.045 1.021 1.008 1.002 1.069 0.625
Figure: Benchmarking of colRanks() and rowRanks() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 integer matrix

> X <- data[["10x1000"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804931 43.0    1442291  77.1  1442291  77.1
Vcells 12279515 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804925 43.0    1442291  77.1  1442291  77.1
Vcells 12284558 93.8   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.3218 0.3823 0.4225 0.3988 0.4566 0.788
apply+rank 56.2760 70.3403 79.6412 80.8709 87.5793 142.845
expr min lq mean median uq max
colRanks 1.0 1 1.0 1.0 1.0 1.0
apply+rank 174.9 184 188.5 202.8 191.8 181.3
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.291 0.2951 0.3405 0.3465 0.3503 0.5401
apply+rank 55.647 63.4144 69.8360 67.9174 72.6635 204.0764
expr min lq mean median uq max
rowRanks 1.0 1.0 1.0 1 1.0 1.0
apply+rank 191.2 214.9 205.1 196 207.4 377.9
Figure: Benchmarking of colRanks() and apply+rank() on integer+10x1000 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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 rowRanks 291.0 295.1 340.5 346.5 350.3 540.1
1 colRanks 321.8 382.3 422.5 398.8 456.6 788.0
expr min lq mean median uq max
2 rowRanks 1.000 1.000 1.000 1.000 1.000 1.000
1 colRanks 1.106 1.296 1.241 1.151 1.303 1.459
Figure: Benchmarking of colRanks() and rowRanks() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 integer matrix

> X <- data[["100x1000"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804966 43.0    1442291  77.1  1442291  77.1
Vcells 12279858 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804960 43.0    1442291  77.1  1442291  77.1
Vcells 12329901 94.1   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 4.616 4.664 5.255 5.019 5.529 10.61
apply+rank 66.844 80.143 90.069 91.047 95.747 124.23
expr min lq mean median uq max
colRanks 1.00 1.00 1.00 1.00 1.00 1.0
apply+rank 14.48 17.18 17.14 18.14 17.32 11.7
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 4.049 4.40 4.782 4.612 5.195 5.655
apply+rank 67.583 76.33 86.739 82.782 93.011 212.121
expr min lq mean median uq max
rowRanks 1.00 1.00 1.00 1.00 1.0 1.00
apply+rank 16.69 17.35 18.14 17.95 17.9 37.51
Figure: Benchmarking of colRanks() and apply+rank() on integer+100x1000 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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 rowRanks 4.049 4.400 4.782 4.612 5.195 5.655
1 colRanks 4.616 4.664 5.255 5.019 5.529 10.614
expr min lq mean median uq max
2 rowRanks 1.00 1.00 1.000 1.000 1.000 1.000
1 colRanks 1.14 1.06 1.099 1.088 1.064 1.877
Figure: Benchmarking of colRanks() and rowRanks() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 integer matrix

> X <- data[["1000x100"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805003 43.0    1442291  77.1  1442291  77.1
Vcells 12280280 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804997 43.0    1442291  77.1  1442291  77.1
Vcells 12330323 94.1   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 5.555 6.245 7.023 7.29 7.689 9.302
apply+rank 21.082 26.730 30.861 29.52 32.120 143.992
expr min lq mean median uq max
colRanks 1.000 1.000 1.000 1.00 1.000 1.00
apply+rank 3.795 4.281 4.394 4.05 4.177 15.48
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 5.331 5.563 6.555 6.465 7.429 10.13
apply+rank 20.240 22.058 27.375 26.859 31.184 66.52
expr min lq mean median uq max
rowRanks 1.000 1.000 1.000 1.000 1.000 1.000
apply+rank 3.796 3.965 4.176 4.154 4.198 6.566
Figure: Benchmarking of colRanks() and apply+rank() on integer+1000x100 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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
2 rowRanks 5.331 5.563 6.555 6.465 7.429 10.131
1 colRanks 5.555 6.245 7.023 7.290 7.689 9.302
expr min lq mean median uq max
2 rowRanks 1.000 1.000 1.000 1.000 1.000 1.0000
1 colRanks 1.042 1.123 1.071 1.128 1.035 0.9182
Figure: Benchmarking of colRanks() and rowRanks() on integer+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Data type "double"

Data

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

Results

10x10 double matrix

> X <- data[["10x10"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805046 43.0    1442291  77.1  1442291  77.1
Vcells 12396419 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805031 43.0    1442291  77.1  1442291  77.1
Vcells 12396547 94.6   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.0227 0.0277 0.0468 0.0385 0.0601 0.0978
apply+rank 0.5963 0.6175 0.7297 0.6298 0.9014 1.3262
expr min lq mean median uq max
colRanks 1.00 1.00 1.0 1.00 1.00 1.00
apply+rank 26.25 22.28 15.6 16.36 15.01 13.56
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.0127 0.0204 0.0351 0.0333 0.047 0.0789
apply+rank 0.6175 0.9206 0.9927 0.9464 1.014 3.9700
expr min lq mean median uq max
rowRanks 1.0 1.00 1.0 1.00 1.0 1.00
apply+rank 48.6 45.12 28.3 28.42 21.6 50.31
Figure: Benchmarking of colRanks() and apply+rank() on double+10x10 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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 rowRanks 12.70 20.40 35.08 33.3 46.97 78.92
1 colRanks 22.71 27.72 46.79 38.5 60.05 97.78
expr min lq mean median uq max
2 rowRanks 1.000 1.000 1.000 1.000 1.000 1.000
1 colRanks 1.788 1.358 1.334 1.156 1.279 1.239
Figure: Benchmarking of colRanks() and rowRanks() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x100 double matrix

> X <- data[["100x100"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805074 43.0    1442291  77.1  1442291  77.1
Vcells 12396430 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805068 43.0    1442291  77.1  1442291  77.1
Vcells 12406473 94.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.4993 0.5718 0.6483 0.6825 0.7181 0.8019
apply+rank 6.5873 7.1349 9.7630 10.2284 10.9937 19.8936
expr min lq mean median uq max
colRanks 1.00 1.00 1.00 1.00 1.00 1.00
apply+rank 13.19 12.48 15.06 14.99 15.31 24.81
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.4727 0.4958 0.5727 0.5399 0.6533 0.7749
apply+rank 6.7336 7.1317 9.0582 8.3650 10.4796 19.3332
expr min lq mean median uq max
rowRanks 1.00 1.00 1.00 1.00 1.00 1.00
apply+rank 14.24 14.38 15.82 15.49 16.04 24.95
Figure: Benchmarking of colRanks() and apply+rank() on double+100x100 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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
2 rowRanks 472.7 495.8 572.7 539.9 653.3 774.9
1 colRanks 499.3 571.8 648.3 682.5 718.1 801.9
expr min lq mean median uq max
2 rowRanks 1.000 1.000 1.000 1.000 1.000 1.000
1 colRanks 1.056 1.153 1.132 1.264 1.099 1.035
Figure: Benchmarking of colRanks() and rowRanks() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x10 double matrix

> X <- data[["1000x10"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805109 43.0    1442291  77.1  1442291  77.1
Vcells 12397126 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805103 43.0    1442291  77.1  1442291  77.1
Vcells 12407169 94.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.6656 0.6742 0.7494 0.7316 0.7418 1.035
apply+rank 2.1288 2.2208 2.4954 2.2566 2.7636 3.455
expr min lq mean median uq max
colRanks 1.000 1.000 1.00 1.000 1.000 1.000
apply+rank 3.198 3.294 3.33 3.084 3.725 3.338
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.6394 0.7622 0.813 0.8173 0.8625 0.952
apply+rank 2.1700 3.1711 3.131 3.2519 3.3481 3.532
expr min lq mean median uq max
rowRanks 1.000 1.00 1.000 1.000 1.000 1.00
apply+rank 3.394 4.16 3.851 3.979 3.882 3.71
Figure: Benchmarking of colRanks() and apply+rank() on double+1000x10 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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
colRanks 665.6 674.2 749.4 731.6 741.8 1035
rowRanks 639.4 762.2 813.0 817.3 862.5 952
expr min lq mean median uq max
colRanks 1.0000 1.000 1.000 1.000 1.000 1.00
rowRanks 0.9607 1.131 1.085 1.117 1.163 0.92
Figure: Benchmarking of colRanks() and rowRanks() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

10x1000 double matrix

> X <- data[["10x1000"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805147 43.0    1442291  77.1  1442291  77.1
Vcells 12397152 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805141 43.0    1442291  77.1  1442291  77.1
Vcells 12407195 94.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 0.3511 0.4217 0.4466 0.4302 0.4693 1.164
apply+rank 56.5898 62.7835 71.7817 69.7821 79.0790 96.098
expr min lq mean median uq max
colRanks 1.0 1.0 1.0 1.0 1.0 1.00
apply+rank 161.2 148.9 160.7 162.2 168.5 82.58
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 0.3064 0.313 0.3898 0.3653 0.4238 0.8196
apply+rank 56.2872 63.234 72.5931 70.1948 77.5813 213.3468
expr min lq mean median uq max
rowRanks 1.0 1 1.0 1.0 1 1.0
apply+rank 183.7 202 186.2 192.1 183 260.3
Figure: Benchmarking of colRanks() and apply+rank() on double+10x1000 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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 rowRanks 306.4 313.0 389.8 365.3 423.8 819.6
1 colRanks 351.1 421.7 446.6 430.2 469.3 1163.7
expr min lq mean median uq max
2 rowRanks 1.000 1.000 1.000 1.000 1.000 1.00
1 colRanks 1.146 1.347 1.146 1.178 1.107 1.42
Figure: Benchmarking of colRanks() and rowRanks() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

100x1000 double matrix

> X <- data[["100x1000"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805182 43.1    1442291  77.1  1442291  77.1
Vcells 12398076 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805176 43.1    1442291  77.1  1442291  77.1
Vcells 12498119 95.4   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 4.919 4.956 5.697 5.231 6.466 9.23
apply+rank 69.764 81.853 93.062 90.987 104.885 135.71
expr min lq mean median uq max
colRanks 1.00 1.00 1.00 1.0 1.00 1.0
apply+rank 14.18 16.52 16.34 17.4 16.22 14.7
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 5.028 5.054 5.356 5.069 5.436 6.513
apply+rank 69.930 80.867 90.392 88.045 95.610 239.730
expr min lq mean median uq max
rowRanks 1.00 1 1.00 1.00 1.00 1.00
apply+rank 13.91 16 16.88 17.37 17.59 36.81
Figure: Benchmarking of colRanks() and apply+rank() on double+100x1000 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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
2 rowRanks 5.028 5.054 5.356 5.069 5.436 6.513
1 colRanks 4.919 4.956 5.697 5.231 6.466 9.230
expr min lq mean median uq max
2 rowRanks 1.0000 1.0000 1.000 1.000 1.000 1.000
1 colRanks 0.9783 0.9806 1.064 1.032 1.189 1.417
Figure: Benchmarking of colRanks() and rowRanks() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

1000x100 double matrix

> X <- data[["1000x100"]]
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805219 43.1    1442291  77.1  1442291  77.1
Vcells 12398101 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanks = colRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 2L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   805213 43.1    1442291  77.1  1442291  77.1
Vcells 12498144 95.4   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanks = rowRanks(X, na.rm = FALSE), `apply+rank` = apply(X, MARGIN = 1L, 
+     FUN = rank, na.last = "keep", ties.method = "max"), unit = "ms")

Table: Benchmarking of colRanks() and apply+rank() 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
colRanks 6.608 7.098 7.898 7.838 8.574 11.36
apply+rank 20.612 26.252 28.988 30.054 30.827 39.66
expr min lq mean median uq max
colRanks 1.000 1.000 1.00 1.000 1.000 1.000
apply+rank 3.119 3.699 3.67 3.835 3.595 3.492
Table: Benchmarking of rowRanks() and apply+rank() 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
rowRanks 6.623 6.664 7.701 7.201 8.491 19.56
apply+rank 20.811 22.743 26.504 25.474 30.661 40.62
expr min lq mean median uq max
rowRanks 1.000 1.000 1.000 1.000 1.000 1.000
apply+rank 3.142 3.413 3.442 3.538 3.611 2.077
Figure: Benchmarking of colRanks() and apply+rank() on double+1000x100 data as well as rowRanks() and apply+rank() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanks() and rowRanks() 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
2 rowRanks 6.623 6.664 7.701 7.201 8.491 19.56
1 colRanks 6.608 7.098 7.898 7.838 8.574 11.36
expr min lq mean median uq max
2 rowRanks 1.0000 1.000 1.000 1.000 1.00 1.0000
1 colRanks 0.9978 1.065 1.026 1.088 1.01 0.5808
Figure: Benchmarking of colRanks() and rowRanks() on double+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

Appendix

Session information

R Under development (unstable) (2015-02-27 r67909)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] markdown_0.7.7          microbenchmark_1.4-2    matrixStats_0.14.0-9000
[4] ggplot2_1.0.0           knitr_1.9.3             R.devices_2.13.0       
[7] R.utils_2.0.0           R.oo_1.19.0             R.methodsS3_1.7.0      

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.4         BiocGenerics_0.13.6 splines_3.2.0      
 [4] MASS_7.3-39         munsell_0.4.2       lattice_0.20-30    
 [7] colorspace_1.2-4    R.cache_0.11.1-9000 multcomp_1.3-9     
[10] stringr_0.6.2       plyr_1.8.1          tools_3.2.0        
[13] parallel_3.2.0      grid_3.2.0          Biobase_2.27.2     
[16] gtable_0.1.2        TH.data_1.0-6       survival_2.38-1    
[19] digest_0.6.8        R.rsp_0.20.0        reshape2_1.4.1     
[22] formatR_1.0.3       base64enc_0.1-3     mime_0.2.1         
[25] evaluate_0.5.7      labeling_0.3        sandwich_2.3-2     
[28] scales_0.2.4        mvtnorm_1.0-2       zoo_1.7-12         
[31] Cairo_1.5-6         proto_0.3-10       

Total processing time was 2.02 mins.

Reproducibility

To reproduce this report, do:

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

Copyright Henrik Bengtsson. Last updated on 2015-03-02 17:21:28 (-0800 UTC). Powered by RSP.

<script> var link = document.createElement('link'); link.rel = 'icon'; link.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAADFBMVEX9/v0AAP/9/v3//wBEQjoBAAAABHRSTlP//wD//gy7CwAAAGJJREFUOI3N0rESwCAIA9Ag///PXdoiBk0HhmbNO49DMETQCexNCSyFgdlGoO5DYOr9ThLgPosA7osIQP0sHuDOog8UI/ALa988wzdwXJRctf4s+d36YPTJ6aMd8ux3+QO4ABTtB85yDAh9AAAAAElFTkSuQmCC" document.getElementsByTagName('head')[0].appendChild(link); </script>

[Benchmark reports](Benchmark reports)

Clone this wiki locally