81 lines
1.6 KiB
Plaintext
81 lines
1.6 KiB
Plaintext
<%@include file="includes/setup.md.rsp"%>
|
|
|
|
<%@string colname="colDiffs"%>
|
|
<%@string rowname="rowDiffs"%>
|
|
<%@meta title="${colname}() and ${rowname}() benchmarks"%>
|
|
<%@meta author="Henrik Bengtsson"%>
|
|
<%@meta date="2014-12-30"%>
|
|
|
|
<%@include file="${header}"%>
|
|
|
|
|
|
# <%@meta name="title"%>
|
|
|
|
This report benchmark the performance of <%=colname%>() and <%=rowname%>() against alternative methods.
|
|
|
|
## Alternative methods
|
|
|
|
* apply() + diff()
|
|
* apply() + diff2()
|
|
* diff()
|
|
|
|
<% for (mode in c("integer", "double")) { %>
|
|
|
|
## Data type "<%=mode%>"
|
|
|
|
### Data
|
|
```r
|
|
<%=withCapture({
|
|
<%@include file="R/random-matrices.R"%>
|
|
data <- rmatrices(mode = mode)
|
|
})%>
|
|
```
|
|
|
|
### Results
|
|
|
|
<% for (dataLabel in names(data)) { %>
|
|
<% mprintf("%s: %s\n", mode, dataLabel) %>
|
|
#### <%=dataLabel%> <%=mode%> matrix
|
|
|
|
|
|
```r
|
|
<%=withCapture({
|
|
X <- data[[.dataLabel.]]
|
|
gc()
|
|
|
|
colStats <- microbenchmark(
|
|
colDiffs = colDiffs(X),
|
|
"apply+diff" = apply(X, MARGIN = 2L, FUN = diff),
|
|
"apply+diff2" = apply(X, MARGIN = 2L, FUN = diff2),
|
|
diff = diff(X),
|
|
unit = "ms"
|
|
)
|
|
|
|
X <- t(X)
|
|
gc()
|
|
|
|
rowStats <- microbenchmark(
|
|
rowDiffs = rowDiffs(X),
|
|
"apply+diff" = apply(X, MARGIN = 1L, FUN = diff),
|
|
"apply+diff2" = apply(X, MARGIN = 1L, FUN = diff2),
|
|
"diff + t" = diff(t(X)),
|
|
unit = "ms"
|
|
)
|
|
})%>
|
|
```
|
|
|
|
<% crBenchmarkResults(colStats, rowStats, tags=c(mode, dataLabel)) %>
|
|
|
|
<% } # for (dataLabel ...) %>
|
|
|
|
<% } # for (mode ...) %>
|
|
|
|
<%@include file="${footer}"%>
|
|
|
|
|
|
<%---------------------------------------------------------------------------
|
|
HISTORY:
|
|
2014-11-17
|
|
o Created.
|
|
---------------------------------------------------------------------------%>
|