<%@include file="includes/setup.md.rsp"%> <%@string fcnname="weightedMedian_subset"%> <%@string subname="weightedMedian"%> <%@meta title="${subname}() benchmarks on subsetted computation"%> <%@meta author="Dongcan Jiang"%> <%@meta date="2015-06-07"%> <%@include file="${header}"%> <% weightedMedian <- matrixStats::weightedMedian %> # <%@meta name="title"%> This report benchmark the performance of <%=subname%>() on subsetted computation. ## Data ```r <%=withCapture({ <%@include file="R/random-vectors.R"%> data <- rvectors(mode = "double") data <- data[1:3] })%> ``` ## Results <% for (ii in seq_along(data)) { %> <% dataLabel <- names(data)[ii] message(dataLabel) %> ### <%=dataLabel%> vector ```r <%=withCapture({ x <- data[[.dataLabel.]] idxs <- sample.int(length(x), size = length(x)*0.7) x_S <- x[idxs] w <- runif(length(x)) w_S <- x[idxs] gc() stats <- microbenchmark( "weightedMedian_x_w_S" = weightedMedian(x_S, w = w_S, ties = "mean", na.rm = FALSE), "weightedMedian(x, w, idxs)" = weightedMedian(x, w = w, idxs = idxs, ties = "mean", na.rm = FALSE), "weightedMedian(x[idxs], w[idxs])" = weightedMedian(x[idxs], w = w[idxs], ties = "mean", na.rm = FALSE), unit = "ms" ) })%> ``` <% benchmarkResults(stats, tags=dataLabel) %> <% } # for (ii ...) %> <%@include file="${footer}"%> <%--------------------------------------------------------------------------- HISTORY: 2015-06-07 o Created. ---------------------------------------------------------------------------%>