-
Notifications
You must be signed in to change notification settings - Fork 0
indexByRow
matrixStats: Benchmark report
This report benchmark the performance of indexByRow() against alternative methods:
-
indexByRow_R1()based inmatrix(..., byrow=TRUE) -
indexByRow_R2()is a modified version ofindexByRow_R1()
where indexByRow_R1() and indexByRow_R2() are defined as in the Appendix.
> data <- rmatrices(mode = "index")where rmatrices() is defined in the Appendix.
> X <- data[["10x10"]]
> dim <- dim(X)
> idxsList <- list(`all-by-NULL` = NULL, all = seq_len(prod(dim)), odd = seq(from = 1, to = prod(dim),
+ by = 2L))
> str(idxsList)
List of 3
$ all-by-NULL: NULL
$ all : int [1:100] 1 2 3 4 5 6 7 8 9 10 ...
$ odd : num [1:50] 1 3 5 7 9 11 13 15 17 19 ...> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x10+all-by-NULL data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.0077 | 0.0129 | 0.0160 | 0.0146 | 0.0166 | 0.0658 |
| indexByRow_R1 | 0.0077 | 0.0142 | 0.0177 | 0.0156 | 0.0177 | 0.0893 |
| indexByRow_R2 | 0.0077 | 0.0142 | 0.0188 | 0.0156 | 0.0185 | 0.1921 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 1 | 1.104 | 1.106 | 1.066 | 1.070 | 1.357 |
| indexByRow_R2 | 1 | 1.104 | 1.171 | 1.066 | 1.116 | 2.918 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x10+all-by-NULL data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x10+all data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.0127 | 0.0152 | 0.0227 | 0.0177 | 0.0204 | 0.2976 |
| indexByRow_R1 | 0.0162 | 0.0181 | 0.0260 | 0.0198 | 0.0239 | 0.2125 |
| indexByRow_R2 | 0.0169 | 0.0196 | 0.0250 | 0.0208 | 0.0277 | 0.0781 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.0000 |
| indexByRow_R1 | 1.273 | 1.190 | 1.149 | 1.119 | 1.170 | 0.7141 |
| indexByRow_R2 | 1.333 | 1.291 | 1.102 | 1.174 | 1.359 | 0.2626 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x10+all data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x10+odd data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 3 | indexByRow_R2 | 0.0119 | 0.0141 | 0.0174 | 0.0158 | 0.0175 | 0.0404 |
| 1 | indexByRow | 0.0131 | 0.0156 | 0.0195 | 0.0181 | 0.0200 | 0.1143 |
| 2 | indexByRow_R1 | 0.0158 | 0.0185 | 0.0227 | 0.0204 | 0.0227 | 0.0624 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 3 | indexByRow_R2 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 1 | indexByRow | 1.097 | 1.110 | 1.120 | 1.146 | 1.143 | 2.829 |
| 2 | indexByRow_R1 | 1.323 | 1.315 | 1.302 | 1.293 | 1.297 | 1.543 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x10+odd data. Outliers are displayed as crosses. Times are in milliseconds. | |||||||
![]() |
> X <- data[["100x100"]]
> dim <- dim(X)
> idxsList <- list(`all-by-NULL` = NULL, all = seq_len(prod(dim)), odd = seq(from = 1, to = prod(dim),
+ by = 2L))
> str(idxsList)
List of 3
$ all-by-NULL: NULL
$ all : int [1:10000] 1 2 3 4 5 6 7 8 9 10 ...
$ odd : num [1:5000] 1 3 5 7 9 11 13 15 17 19 ...> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x100+all-by-NULL data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | indexByRow | 0.0177 | 0.0219 | 0.0302 | 0.0266 | 0.0341 | 0.0720 |
| 3 | indexByRow_R2 | 0.1170 | 0.1190 | 0.1393 | 0.1205 | 0.1336 | 0.3033 |
| 2 | indexByRow_R1 | 0.1170 | 0.1193 | 0.1433 | 0.1216 | 0.1447 | 0.2956 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| 3 | indexByRow_R2 | 6.608 | 5.421 | 4.620 | 4.536 | 3.921 | 4.214 |
| 2 | indexByRow_R1 | 6.608 | 5.438 | 4.753 | 4.580 | 4.248 | 4.107 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x100+all-by-NULL data. Outliers are displayed as crosses. Times are in milliseconds. | |||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x100+all data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.1109 | 0.1709 | 0.1917 | 0.1967 | 0.2233 | 0.3022 |
| indexByRow_R1 | 0.1728 | 0.2695 | 0.2836 | 0.2947 | 0.3162 | 0.4465 |
| indexByRow_R2 | 0.5801 | 0.7709 | 0.8210 | 0.8038 | 0.9216 | 1.2592 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 1.559 | 1.577 | 1.479 | 1.498 | 1.416 | 1.478 |
| indexByRow_R2 | 5.233 | 4.510 | 4.282 | 4.086 | 4.128 | 4.167 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x100+all data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x100+odd data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.1186 | 0.1247 | 0.1445 | 0.1324 | 0.1625 | 0.2148 |
| indexByRow_R1 | 0.2729 | 0.2899 | 0.3031 | 0.2968 | 0.3105 | 0.4658 |
| indexByRow_R2 | 0.3565 | 0.3830 | 0.3861 | 0.3863 | 0.3915 | 0.4123 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 2.302 | 2.324 | 2.098 | 2.241 | 1.911 | 2.168 |
| indexByRow_R2 | 3.006 | 3.071 | 2.672 | 2.917 | 2.410 | 1.919 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x100+odd data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> X <- data[["1000x10"]]
> dim <- dim(X)
> idxsList <- list(`all-by-NULL` = NULL, all = seq_len(prod(dim)), odd = seq(from = 1, to = prod(dim),
+ by = 2L))
> str(idxsList)
List of 3
$ all-by-NULL: NULL
$ all : int [1:10000] 1 2 3 4 5 6 7 8 9 10 ...
$ odd : num [1:5000] 1 3 5 7 9 11 13 15 17 19 ...> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x10+all-by-NULL data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.0304 | 0.0339 | 0.0389 | 0.0364 | 0.0400 | 0.0858 |
| indexByRow_R1 | 0.1971 | 0.1998 | 0.2050 | 0.2009 | 0.2092 | 0.2983 |
| indexByRow_R2 | 0.1963 | 0.1990 | 0.2050 | 0.2009 | 0.2102 | 0.2776 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 6.481 | 5.898 | 5.266 | 5.524 | 5.226 | 3.475 |
| indexByRow_R2 | 6.455 | 5.875 | 5.264 | 5.524 | 5.250 | 3.233 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x10+all-by-NULL data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x10+all data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.1113 | 0.1134 | 0.1480 | 0.1247 | 0.1719 | 0.2645 |
| indexByRow_R1 | 0.1721 | 0.1763 | 0.2246 | 0.1825 | 0.2951 | 0.3892 |
| indexByRow_R2 | 0.5582 | 0.5618 | 0.6793 | 0.5655 | 0.8486 | 1.0155 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 1.547 | 1.555 | 1.518 | 1.463 | 1.717 | 1.472 |
| indexByRow_R2 | 5.017 | 4.956 | 4.590 | 4.534 | 4.937 | 3.840 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x10+all data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x10+odd data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.1213 | 0.1292 | 0.1425 | 0.1355 | 0.1538 | 0.2144 |
| indexByRow_R1 | 0.2656 | 0.2904 | 0.3008 | 0.3001 | 0.3091 | 0.3399 |
| indexByRow_R2 | 0.3611 | 0.3828 | 0.3956 | 0.3942 | 0.4042 | 0.4797 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 2.191 | 2.249 | 2.111 | 2.215 | 2.010 | 1.585 |
| indexByRow_R2 | 2.978 | 2.964 | 2.777 | 2.909 | 2.628 | 2.237 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x10+odd data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> X <- data[["10x1000"]]
> dim <- dim(X)
> idxsList <- list(`all-by-NULL` = NULL, all = seq_len(prod(dim)), odd = seq(from = 1, to = prod(dim),
+ by = 2L))
> str(idxsList)
List of 3
$ all-by-NULL: NULL
$ all : int [1:10000] 1 2 3 4 5 6 7 8 9 10 ...
$ odd : num [1:5000] 1 3 5 7 9 11 13 15 17 19 ...> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x1000+all-by-NULL data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.0289 | 0.0323 | 0.0396 | 0.0364 | 0.0395 | 0.1297 |
| indexByRow_R1 | 0.1790 | 0.1840 | 0.1994 | 0.2027 | 0.2073 | 0.2518 |
| indexByRow_R2 | 0.1763 | 0.1829 | 0.1988 | 0.2029 | 0.2092 | 0.2264 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 6.200 | 5.690 | 5.041 | 5.571 | 5.253 | 1.941 |
| indexByRow_R2 | 6.106 | 5.655 | 5.026 | 5.577 | 5.302 | 1.745 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x1000+all-by-NULL data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x1000+all data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.1744 | 0.2044 | 0.2352 | 0.2331 | 0.2510 | 0.4004 |
| indexByRow_R1 | 0.2425 | 0.3078 | 0.3294 | 0.3259 | 0.3455 | 0.4877 |
| indexByRow_R2 | 0.8126 | 0.9245 | 0.9443 | 0.9374 | 0.9607 | 1.1129 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 1.391 | 1.506 | 1.401 | 1.398 | 1.377 | 1.218 |
| indexByRow_R2 | 4.660 | 4.523 | 4.015 | 4.021 | 3.827 | 2.780 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x1000+all data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x1000+odd data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.0755 | 0.0824 | 0.1198 | 0.1268 | 0.1411 | 0.2017 |
| indexByRow_R1 | 0.1775 | 0.1882 | 0.2555 | 0.2808 | 0.3026 | 0.3857 |
| indexByRow_R2 | 0.2776 | 0.2860 | 0.3788 | 0.4107 | 0.4473 | 0.5131 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 2.352 | 2.285 | 2.133 | 2.214 | 2.145 | 1.912 |
| indexByRow_R2 | 3.679 | 3.472 | 3.162 | 3.238 | 3.171 | 2.544 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 10x1000+odd data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> X <- data[["100x1000"]]
> dim <- dim(X)
> idxsList <- list(`all-by-NULL` = NULL, all = seq_len(prod(dim)), odd = seq(from = 1, to = prod(dim),
+ by = 2L))
> str(idxsList)
List of 3
$ all-by-NULL: NULL
$ all : int [1:100000] 1 2 3 4 5 6 7 8 9 10 ...
$ odd : num [1:50000] 1 3 5 7 9 11 13 15 17 19 ...> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x1000+all-by-NULL data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.1163 | 0.2215 | 0.2909 | 0.2593 | 0.3642 | 0.5532 |
| indexByRow_R1 | 1.1275 | 1.4767 | 1.8302 | 1.7702 | 2.1219 | 2.6523 |
| indexByRow_R2 | 1.1271 | 1.6638 | 2.0902 | 1.8353 | 2.2481 | 21.8200 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 9.699 | 6.665 | 6.292 | 6.828 | 5.827 | 4.795 |
| indexByRow_R2 | 9.695 | 7.510 | 7.185 | 7.079 | 6.173 | 39.445 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x1000+all-by-NULL data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x1000+all data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.068 | 1.648 | 1.889 | 1.843 | 2.053 | 3.886 |
| indexByRow_R1 | 1.779 | 2.751 | 3.454 | 3.054 | 3.545 | 27.781 |
| indexByRow_R2 | 6.295 | 7.829 | 9.726 | 9.376 | 10.414 | 32.519 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 1.666 | 1.669 | 1.828 | 1.657 | 1.727 | 7.149 |
| indexByRow_R2 | 5.896 | 4.751 | 5.149 | 5.088 | 5.074 | 8.368 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x1000+all data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x1000+odd data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.090 | 1.200 | 1.361 | 1.272 | 1.361 | 3.706 |
| indexByRow_R1 | 2.753 | 3.014 | 4.098 | 3.236 | 3.683 | 35.035 |
| indexByRow_R2 | 3.332 | 4.046 | 4.641 | 4.257 | 4.728 | 18.979 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 2.526 | 2.511 | 3.011 | 2.544 | 2.706 | 9.453 |
| indexByRow_R2 | 3.057 | 3.372 | 3.410 | 3.346 | 3.475 | 5.121 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 100x1000+odd data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> X <- data[["1000x100"]]
> dim <- dim(X)
> idxsList <- list(`all-by-NULL` = NULL, all = seq_len(prod(dim)), odd = seq(from = 1, to = prod(dim),
+ by = 2L))
> str(idxsList)
List of 3
$ all-by-NULL: NULL
$ all : int [1:100000] 1 2 3 4 5 6 7 8 9 10 ...
$ odd : num [1:50000] 1 3 5 7 9 11 13 15 17 19 ...> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x100+all-by-NULL data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.1859 | 0.2385 | 0.3671 | 0.2514 | 0.4054 | 6.04 |
| indexByRow_R1 | 1.6580 | 2.0123 | 2.3841 | 2.1594 | 2.6747 | 7.32 |
| indexByRow_R2 | 1.6796 | 2.0021 | 2.5473 | 2.2491 | 2.6683 | 19.24 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 8.917 | 8.438 | 6.495 | 8.590 | 6.598 | 1.212 |
| indexByRow_R2 | 9.033 | 8.395 | 6.940 | 8.947 | 6.583 | 3.185 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x100+all-by-NULL data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x100+all data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.134 | 1.643 | 1.776 | 1.712 | 1.874 | 5.208 |
| indexByRow_R1 | 1.987 | 2.814 | 3.138 | 3.008 | 3.412 | 8.191 |
| indexByRow_R2 | 6.961 | 8.099 | 9.872 | 8.717 | 9.719 | 45.456 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
| indexByRow_R1 | 1.752 | 1.713 | 1.766 | 1.758 | 1.820 | 1.573 |
| indexByRow_R2 | 6.138 | 4.930 | 5.557 | 5.093 | 5.186 | 8.727 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x100+all data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
> stats <- microbenchmark(indexByRow = indexByRow(dim, idxs = idxs), indexByRow_R1 = indexByRow_R1(dim,
+ idxs = idxs), indexByRow_R2 = indexByRow_R2(dim, idxs = idxs), unit = "ms")Table: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x100+odd data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 0.681 | 1.115 | 1.372 | 1.214 | 1.296 | 17.532 |
| indexByRow_R1 | 1.797 | 2.836 | 2.982 | 2.972 | 3.187 | 6.456 |
| indexByRow_R2 | 2.896 | 3.826 | 4.104 | 4.007 | 4.485 | 7.450 |
| expr | min | lq | mean | median | uq | max |
|---|---|---|---|---|---|---|
| indexByRow | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.0000 |
| indexByRow_R1 | 2.639 | 2.545 | 2.174 | 2.448 | 2.459 | 0.3683 |
| indexByRow_R2 | 4.253 | 3.433 | 2.992 | 3.300 | 3.461 | 0.4250 |
| Figure: Benchmarking of indexByRow(), indexByRow_R1() and indexByRow_R2() on 1000x100+odd data. Outliers are displayed as crosses. Times are in milliseconds. | ||||||
![]() |
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 GenomeInfoDb_1.3.13 formatR_1.0.3
[4] plyr_1.8.1 base64enc_0.1-3 tools_3.2.0
[7] digest_0.6.8 RSQLite_1.0.0 annotate_1.45.2
[10] evaluate_0.5.7 gtable_0.1.2 R.cache_0.11.1-9000
[13] lattice_0.20-30 DBI_0.3.1 parallel_3.2.0
[16] mvtnorm_1.0-2 proto_0.3-10 R.rsp_0.20.0
[19] genefilter_1.49.2 stringr_0.6.2 IRanges_2.1.41
[22] S4Vectors_0.5.21 stats4_3.2.0 grid_3.2.0
[25] Biobase_2.27.2 AnnotationDbi_1.29.17 XML_3.98-1.1
[28] survival_2.38-1 multcomp_1.3-9 TH.data_1.0-6
[31] reshape2_1.4.1 scales_0.2.4 MASS_7.3-39
[34] splines_3.2.0 BiocGenerics_0.13.6 xtable_1.8-0
[37] mime_0.2.1 colorspace_1.2-4 labeling_0.3
[40] sandwich_2.3-2 munsell_0.4.2 Cairo_1.5-6
[43] zoo_1.7-12 Total processing time was 33.31 secs.
To reproduce this report, do:
html <- matrixStats:::benchmark('indexByRow')Copyright Henrik Bengtsson. Last updated on 2015-03-02 17:27:44 (-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>> indexByRow_R1 <- function(dim, idxs = NULL, ...) {
+ n <- prod(dim)
+ x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE)
+ if (!is.null(idxs))
+ x <- x[idxs]
+ as.vector(x)
+ }> indexByRow_R2 <- function(dim, idxs = NULL, ...) {
+ n <- prod(dim)
+ if (is.null(idxs)) {
+ x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE)
+ as.vector(x)
+ } else {
+ idxs <- idxs - 1
+ cols <- idxs%/%dim[2L]
+ rows <- idxs%%dim[2L]
+ cols + dim[1L] * rows + 1L
+ }
+ }> 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
+ }[Benchmark reports](Benchmark reports)

















