<%@include file="includes/setup.md.rsp"%>

<%@string fcnname="mean2_subset"%>
<%@string subname="mean2"%>
<%@meta title="${subname}() benchmarks on subsetted computation"%>
<%@meta author="Dongcan Jiang"%>
<%@meta date="2015-06-07"%>

<%@include file="${header}"%>


# <%@meta name="title"%>

This report benchmark the performance of <%=subname%>() on subsetted computation.


<% for (mode in c("integer", "double")) { %>

## Data type "<%=mode%>"
### Data
```r
<%=withCapture({
<%@include file="R/random-vectors.R"%>
data <- rvectors(mode = mode)
##data <- data[1:3]
})%>
```

### Results

<% for (ii in seq_along(data)) { %>
<%
dataLabel <- names(data)[ii]
mprintf("%s: %s\n", mode, dataLabel)
%>
### <%=dataLabel%> vector


```r
<%=withCapture({
x <- data[[.dataLabel.]]
idxs <- sample.int(length(x), size = length(x)*0.7)
x_S <- x[idxs]
gc()

stats <- microbenchmark(
 "mean2_x_S"                = mean2(x_S, refine = TRUE),
 "mean2_x_S_no_refine"      = mean2(x_S, refine = FALSE),
 "mean2(x, idxs)"            = mean2(x, idxs = idxs, refine = TRUE),
 "mean2_no_refine(x, idxs)"  = mean2(x, idxs = idxs, refine = FALSE),
 "mean2(x[idxs])"           = mean2(x[idxs], refine = TRUE),
 "mean2_no_refine(x[idxs])" = mean2(x[idxs], refine = FALSE),
  unit = "ms"
)
})%>
```

<% benchmarkResults(stats, tags=c(mode, dataLabel)) %>

<% } # for (ii ...) %>

<% } # for (mode ...) %>

<%@include file="${footer}"%>


<%---------------------------------------------------------------------------
HISTORY:
2015-06-07
o Created.
---------------------------------------------------------------------------%>
