Skip to content

colRowRanges

hb edited this page Mar 3, 2015 · 2 revisions

matrixStats: Benchmark report


colRanges() and rowRanges() benchmarks

This report benchmark the performance of colRanges() and rowRanges() against alternative methods.

Alternative methods

  • apply() + range()

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   805033 43.0    1442291  77.1  1442291  77.1
Vcells 12279862 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   803947 43.0    1442291  77.1  1442291  77.1
Vcells 12276762 93.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.0046 0.0065 0.0154 0.0087 0.0117 0.323
apply+range 0.0997 0.1646 0.2359 0.1778 0.1879 5.933
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.00 1 1.00
apply+range 21.58 25.14 15.32 20.53 16 18.37
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0050 0.0067 0.0109 0.0090 0.0116 0.1394
apply+range 0.1471 0.1676 0.1784 0.1736 0.1809 0.4450
expr min lq mean median uq max
rowRanges 1.00 1.00 1.00 1.00 1.00 1.000
apply+range 29.38 24.88 16.31 19.19 15.66 3.193
Figure: Benchmarking of colRanges() and apply+range() on integer+10x10 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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
colRanges 4.620 6.545 15.40 8.662 11.74 323.0
rowRanges 5.005 6.738 10.94 9.047 11.55 139.4
expr min lq mean median uq max
colRanges 1.000 1.00 1.0000 1.000 1.0000 1.0000
rowRanges 1.083 1.03 0.7105 1.044 0.9836 0.4315
Figure: Benchmarking of colRanges() and rowRanges() 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   804053 43.0    1442291  77.1  1442291  77.1
Vcells 12277863 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804047 43.0    1442291  77.1  1442291  77.1
Vcells 12282906 93.8   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.0343 0.0362 0.0496 0.0439 0.0549 0.1902
apply+range 0.7383 0.8309 1.0708 1.1279 1.2446 1.5987
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.0 1.00 1.000
apply+range 21.55 22.96 21.58 25.7 22.69 8.407
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0462 0.0489 0.2337 0.0662 0.078 16.71
apply+range 1.2561 1.3520 1.8275 1.4878 1.587 36.62
expr min lq mean median uq max
rowRanges 1.00 1.00 1.000 1.00 1.00 1.000
apply+range 27.19 27.65 7.821 22.47 20.35 2.191
Figure: Benchmarking of colRanges() and apply+range() on integer+100x100 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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
colRanges 34.26 36.19 49.61 43.89 54.86 190.2
rowRanges 46.20 48.89 233.68 66.21 77.95 16712.8
expr min lq mean median uq max
colRanges 1.000 1.000 1.00 1.000 1.000 1.00
rowRanges 1.348 1.351 4.71 1.509 1.421 87.88
Figure: Benchmarking of colRanges() and rowRanges() 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   804088 43.0    1442291  77.1  1442291  77.1
Vcells 12277886 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804082 43.0    1442291  77.1  1442291  77.1
Vcells 12282929 93.8   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.0293 0.0427 0.0492 0.0475 0.0550 0.1001
apply+range 0.5220 0.5514 0.5881 0.5749 0.6163 0.8088
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.00 1.0 1.000
apply+range 17.84 12.91 11.96 12.09 11.2 8.081
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0524 0.0577 0.0647 0.0616 0.0672 0.1193
apply+range 0.5078 0.5476 0.8775 0.5595 0.6082 29.6003
expr min lq mean median uq max
rowRanges 1.000 1.000 1.00 1.000 1.000 1
apply+range 9.698 9.483 13.56 9.084 9.054 248
Figure: Benchmarking of colRanges() and apply+range() on integer+1000x10 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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
colRanges 29.26 42.73 49.18 47.54 55.05 100.1
rowRanges 52.35 57.74 64.70 61.59 67.18 119.3
expr min lq mean median uq max
colRanges 1.000 1.000 1.000 1.000 1.00 1.000
rowRanges 1.789 1.351 1.315 1.296 1.22 1.192
Figure: Benchmarking of colRanges() and rowRanges() 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   804126 43.0    1442291  77.1  1442291  77.1
Vcells 12278463 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804120 43.0    1442291  77.1  1442291  77.1
Vcells 12283506 93.8   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.0793 0.0828 0.0995 0.1055 0.1118 0.1509
apply+range 8.0571 8.5797 9.9144 8.9132 9.7031 41.1724
expr min lq mean median uq max
colRanges 1.0 1.0 1.00 1.0 1.00 1.0
apply+range 101.6 103.7 99.64 84.5 86.77 272.8
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0758 0.0781 0.0929 0.0924 0.1051 0.1424
apply+range 8.1868 8.5968 9.5285 8.8701 9.3623 29.3173
expr min lq mean median uq max
rowRanges 1 1 1.0 1.00 1.00 1.0
apply+range 108 110 102.6 96.01 89.09 205.8
Figure: Benchmarking of colRanges() and apply+range() on integer+10x1000 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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 rowRanges 75.84 78.15 92.89 92.39 105.1 142.4
1 colRanges 79.30 82.77 99.50 105.48 111.8 150.9
expr min lq mean median uq max
2 rowRanges 1.000 1.000 1.000 1.000 1.000 1.00
1 colRanges 1.046 1.059 1.071 1.142 1.064 1.06
Figure: Benchmarking of colRanges() and rowRanges() 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   804161 43.0    1442291  77.1  1442291  77.1
Vcells 12278804 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804155 43.0    1442291  77.1  1442291  77.1
Vcells 12328847 94.1   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.3261 0.3911 0.4213 0.4161 0.4379 1.043
apply+range 7.8823 11.5018 13.1821 12.7656 13.7377 27.096
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.00 1.00 1.00
apply+range 24.17 29.41 31.29 30.68 31.37 25.98
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.3503 0.3838 0.4056 0.3903 0.4279 0.5563
apply+range 8.1934 9.2747 11.7391 11.4503 13.1059 22.4698
expr min lq mean median uq max
rowRanges 1.00 1.00 1.00 1.00 1.00 1.00
apply+range 23.39 24.17 28.94 29.33 30.63 40.39
Figure: Benchmarking of colRanges() and apply+range() on integer+100x1000 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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 rowRanges 350.3 383.8 405.6 390.3 427.9 556.3
1 colRanges 326.1 391.1 421.3 416.1 437.9 1042.8
expr min lq mean median uq max
2 rowRanges 1.0000 1.000 1.000 1.000 1.000 1.000
1 colRanges 0.9308 1.019 1.039 1.066 1.023 1.875
Figure: Benchmarking of colRanges() and rowRanges() 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   804198 43.0    1442291  77.1  1442291  77.1
Vcells 12279211 93.7   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804192 43.0    1442291  77.1  1442291  77.1
Vcells 12329254 94.1   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.1963 0.2837 0.3215 0.2968 0.3318 1.917
apply+range 2.8171 4.1400 4.3449 4.2383 4.4934 5.725
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.00 1.00 1.000
apply+range 14.35 14.59 13.52 14.28 13.54 2.986
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.2633 0.3946 0.4344 0.4631 0.4947 0.5382
apply+range 2.7235 4.9189 5.2305 5.1759 5.5957 8.6934
expr min lq mean median uq max
rowRanges 1.00 1.00 1.00 1.00 1.00 1.00
apply+range 10.34 12.47 12.04 11.18 11.31 16.15
Figure: Benchmarking of colRanges() and apply+range() on integer+1000x100 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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
colRanges 196.3 283.7 321.5 296.8 331.8 1917.1
rowRanges 263.3 394.6 434.4 463.1 494.7 538.2
expr min lq mean median uq max
colRanges 1.000 1.000 1.000 1.00 1.000 1.0000
rowRanges 1.341 1.391 1.351 1.56 1.491 0.2807
Figure: Benchmarking of colRanges() and rowRanges() 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   804241 43.0    1442291  77.1  1442291  77.1
Vcells 12395358 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804226 43.0    1442291  77.1  1442291  77.1
Vcells 12395486 94.6   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.0031 0.0042 0.0062 0.0064 0.0073 0.0231
apply+range 0.1009 0.1047 0.1120 0.1068 0.1086 0.3445
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.00 1.00 1.00
apply+range 32.74 24.72 18.13 16.82 14.84 14.92
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0038 0.0050 0.0068 0.0065 0.0081 0.0254
apply+range 0.1012 0.1055 0.1103 0.1074 0.1097 0.2749
expr min lq mean median uq max
rowRanges 1.0 1.00 1.00 1.00 1.00 1.00
apply+range 26.3 21.07 16.28 16.41 13.57 10.82
Figure: Benchmarking of colRanges() and apply+range() on double+10x10 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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
colRanges 3.081 4.236 6.179 6.353 7.316 23.10
rowRanges 3.850 5.005 6.776 6.545 8.085 25.41
expr min lq mean median uq max
colRanges 1.00 1.000 1.000 1.00 1.000 1.0
rowRanges 1.25 1.181 1.097 1.03 1.105 1.1
Figure: Benchmarking of colRanges() and rowRanges() 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   804269 43.0    1442291  77.1  1442291  77.1
Vcells 12395369 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804263 43.0    1442291  77.1  1442291  77.1
Vcells 12405412 94.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.062 0.0839 0.0942 0.0947 0.1066 0.1278
apply+range 0.962 1.3296 1.3875 1.3885 1.4474 1.6245
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.00 1.00 1.00
apply+range 15.52 15.84 14.72 14.66 13.57 12.71
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0554 0.0678 0.0915 0.0918 0.1151 0.229
apply+range 0.7784 0.9637 1.3737 1.4309 1.5354 5.086
expr min lq mean median uq max
rowRanges 1.00 1.00 1.00 1.00 1.00 1.00
apply+range 14.04 14.22 15.01 15.58 13.34 22.21
Figure: Benchmarking of colRanges() and apply+range() on double+100x100 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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 rowRanges 55.43 67.75 91.50 91.81 115.1 229.0
1 colRanges 61.98 83.92 94.24 94.70 106.6 127.8
expr min lq mean median uq max
2 rowRanges 1.000 1.000 1.00 1.000 1.0000 1.000
1 colRanges 1.118 1.239 1.03 1.031 0.9264 0.558
Figure: Benchmarking of colRanges() and rowRanges() 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   804304 43.0    1442291  77.1  1442291  77.1
Vcells 12396062 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804298 43.0    1442291  77.1  1442291  77.1
Vcells 12406105 94.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.0531 0.0547 0.0660 0.0601 0.0751 0.1340
apply+range 0.3499 0.3563 0.4615 0.4310 0.5532 0.8573
expr min lq mean median uq max
colRanges 1.000 1.000 1.00 1.000 1.000 1.000
apply+range 6.587 6.518 6.99 7.176 7.369 6.399
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0489 0.0500 0.0538 0.0531 0.0550 0.1093
apply+range 0.3465 0.3561 0.3869 0.3607 0.4321 0.6125
expr min lq mean median uq max
rowRanges 1.000 1.000 1.000 1.00 1.00 1.000
apply+range 7.087 7.115 7.191 6.79 7.85 5.602
Figure: Benchmarking of colRanges() and apply+range() on double+1000x10 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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
2 rowRanges 48.89 50.05 53.81 53.12 55.05 109.3
1 colRanges 53.12 54.66 66.03 60.05 75.07 134.0
expr min lq mean median uq max
2 rowRanges 1.000 1.000 1.000 1.00 1.000 1.000
1 colRanges 1.087 1.092 1.227 1.13 1.364 1.225
Figure: Benchmarking of colRanges() and rowRanges() 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   804342 43.0    1442291  77.1  1442291  77.1
Vcells 12396088 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804336 43.0    1442291  77.1  1442291  77.1
Vcells 12406131 94.7   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.1001 0.1272 0.1426 0.1345 0.1538 0.3996
apply+range 5.1757 6.7754 8.0090 8.5032 8.7750 12.9806
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.0 1.00 1.00
apply+range 51.71 53.25 56.15 63.2 57.06 32.49
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.0897 0.1172 0.1255 0.1222 0.1444 0.1898
apply+range 5.1876 5.6340 8.0227 8.3831 8.9481 13.6628
expr min lq mean median uq max
rowRanges 1.00 1.00 1.00 1.00 1.00 1.00
apply+range 57.84 48.06 63.91 68.59 61.98 71.99
Figure: Benchmarking of colRanges() and apply+range() on double+10x1000 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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 rowRanges 89.69 117.2 125.5 122.2 144.4 189.8
1 colRanges 100.09 127.2 142.6 134.5 153.8 399.6
expr min lq mean median uq max
2 rowRanges 1.000 1.000 1.000 1.000 1.000 1.000
1 colRanges 1.116 1.085 1.136 1.101 1.065 2.106
Figure: Benchmarking of colRanges() and rowRanges() 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   804377 43.0    1442291  77.1  1442291  77.1
Vcells 12397008 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804371 43.0    1442291  77.1  1442291  77.1
Vcells 12497051 95.4   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.5978 0.6113 0.7082 0.6665 0.8003 0.8993
apply+range 8.2700 8.8984 11.9058 11.4655 13.4822 27.7263
expr min lq mean median uq max
colRanges 1.00 1.00 1.00 1.0 1.00 1.00
apply+range 13.83 14.56 16.81 17.2 16.85 30.83
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.5228 0.5324 0.6375 0.5717 0.7622 0.9431
apply+range 9.1326 9.9736 13.3663 10.5452 13.2749 152.8659
expr min lq mean median uq max
rowRanges 1.00 1.00 1.00 1.00 1.00 1.0
apply+range 17.47 18.73 20.97 18.45 17.42 162.1
Figure: Benchmarking of colRanges() and apply+range() on double+100x1000 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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 rowRanges 522.8 532.4 637.5 571.7 762.2 943.1
1 colRanges 597.8 611.3 708.2 666.5 800.3 899.3
expr min lq mean median uq max
2 rowRanges 1.000 1.000 1.000 1.000 1.00 1.0000
1 colRanges 1.144 1.148 1.111 1.166 1.05 0.9535
Figure: Benchmarking of colRanges() and rowRanges() 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   804414 43.0    1442291  77.1  1442291  77.1
Vcells 12397033 94.6   35610798 271.7 68120027 519.8
> colStats <- microbenchmark(colRanges = colRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 2L, 
+     FUN = range, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
           used (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   804408 43.0    1442291  77.1  1442291  77.1
Vcells 12497076 95.4   35610798 271.7 68120027 519.8
> rowStats <- microbenchmark(rowRanges = rowRanges(X, na.rm = FALSE), `apply+range` = apply(X, MARGIN = 1L, 
+     FUN = range, na.rm = FALSE), unit = "ms")

Table: Benchmarking of colRanges() and apply+range() 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
colRanges 0.5147 0.5653 0.6685 0.7014 0.732 0.8881
apply+range 2.9969 3.9421 4.9898 5.2325 5.495 16.4171
expr min lq mean median uq max
colRanges 1.000 1.000 1.000 1.00 1.000 1.00
apply+range 5.823 6.973 7.465 7.46 7.507 18.49
Table: Benchmarking of rowRanges() and apply+range() 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
rowRanges 0.4531 0.6492 0.7459 0.7982 0.8203 1.424
apply+range 3.0323 4.9026 5.6746 5.9891 6.3460 12.859
expr min lq mean median uq max
rowRanges 1.000 1.000 1.000 1.000 1.000 1.000
apply+range 6.692 7.551 7.608 7.503 7.736 9.028
Figure: Benchmarking of colRanges() and apply+range() on double+1000x100 data as well as rowRanges() and apply+range() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colRanges() and rowRanges() 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
colRanges 514.7 565.3 668.5 701.4 732.0 888.1
rowRanges 453.1 649.2 745.9 798.2 820.3 1424.3
expr min lq mean median uq max
colRanges 1.0000 1.000 1.000 1.000 1.000 1.000
rowRanges 0.8803 1.149 1.116 1.138 1.121 1.604
Figure: Benchmarking of colRanges() and rowRanges() 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 48.14 secs.

Reproducibility

To reproduce this report, do:

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

Copyright Henrik Bengtsson. Last updated on 2015-03-02 17:19:22 (-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