2025-01-12 04:36:52 +08:00

95 lines
2.0 KiB
Plaintext

<%@include file="includes/setup.md.rsp"%>
<%@string colname="colCounts"%>
<%@string rowname="rowCounts"%>
<%@string fcnname="colRowCounts_subset"%>
<%@meta title="${colname}() and ${rowname}() benchmarks on subsetted computation"%>
<%@meta author="Dongcan Jiang"%>
<%@meta date="2015-04-18"%>
<%@include file="${header}"%>
# <%@meta name="title"%>
This report benchmark the performance of <%=colname%>() and <%=rowname%>() on subsetted computation.
<% for (mode in c("logical", "integer", "double")) { %>
## Data type "<%=mode%>"
### Data
```r
<%=withCapture({
<%@include file="R/random-matrices.R"%>
data <- rmatrices(mode = mode)
})%>
```
### Results
<% for (dataLabel in names(data)) { %>
<% message(dataLabel) %>
#### <%=dataLabel%> matrix
```r
<%=withCapture({
X <- data[[.dataLabel.]]
rows <- sample.int(nrow(X), size = nrow(X)*0.7)
cols <- sample.int(ncol(X), size = ncol(X)*0.7)
X_S <- X[rows, cols]
value <- 42
})%>
```
<% gc() %>
```r
<%=withCapture({
colStats <- microbenchmark(
"colCounts_X_S" = colCounts(X_S, value = value, na.rm = FALSE),
"colCounts(X, rows, cols)" = colCounts(X, value = value, na.rm = FALSE, rows = rows, cols = cols),
"colCounts(X[rows, cols])" = colCounts(X[rows, cols], value = value, na.rm = FALSE),
unit = "ms"
)
})%>
```
```r
<%=withCapture({
X <- t(X)
X_S <- t(X_S)
})%>
```
<% gc() %>
```r
<%=withCapture({
rowStats <- microbenchmark(
"rowCounts_X_S" = rowCounts(X_S, value = value, na.rm = FALSE),
"rowCounts(X, cols, rows)" = rowCounts(X, value = value, na.rm = FALSE, rows = cols, cols = rows),
"rowCounts(X[cols, rows])" = rowCounts(X[cols, rows], value = value, na.rm = FALSE),
unit = "ms"
)
})%>
```
<% crBenchmarkResults(colStats, rowStats, tags=c(mode, dataLabel)) %>
<% } # for (dataLabel ...) %>
<% } # for (mode ...) %>
<%@include file="${footer}"%>
<%---------------------------------------------------------------------------
HISTORY:
2015-04-18
o Created.
---------------------------------------------------------------------------%>