<%@include file="includes/setup.md.rsp"%> <%@string fcnname="t_tx_OP_y_subset"%> <%@string subname="t_tx_OP_y"%> <%@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-matrices.R"%> data <- rmatrices(mode = mode) })%> ``` ### Results <% for (ii in seq_along(data)) { %> <% dataLabel <- names(data)[ii] mprintf("%s: %s\n", mode, dataLabel) %> ### <%=dataLabel%> vector ```r <%=withCapture({ x <- data[[.dataLabel.]] y <- x[, 1L] xrows <- sample.int(nrow(x), size = nrow(x)*0.7) xcols <- sample.int(ncol(x), size = ncol(x)*0.7) x_S <- x[xrows, xcols] yidxs <- xrows y_S <- y[yidxs] })%> ``` <% for (OP in c("+", "-", "*", "/")) { %> <% OPTag <- c("+" = "add", "-" = "sub", "*" = "mul", "/" = "div")[OP] gc() %> ```r <%=withCapture({ OP stats <- microbenchmark( "t_tx_OP_y_x_y_S" = t_tx_OP_y(x_S, y_S, OP = OP, na.rm = FALSE), "t_tx_OP_y(x, y, OP, xrows, xcols, yidxs)" = t_tx_OP_y(x, y, OP = OP, xrows = xrows, xcols = xcols, yidxs = yidxs, na.rm = FALSE), "t_tx_OP_y(x[xrows, xcols], y[yidxs], OP)" = t_tx_OP_y(x[xrows, xcols], y[yidxs], OP = OP, na.rm = FALSE), unit = "ms" ) })%> ``` <% benchmarkResults(stats, tags=c(mode, dataLabel, OPTag)) %> <% } # for (OP ...) %> <% } # for (ii ...) %> <% } # for (mode ...) %> <%@include file="${footer}"%> <%--------------------------------------------------------------------------- HISTORY: 2015-06-07 o Created. ---------------------------------------------------------------------------%>