1<%@include file="includes/setup.md.rsp"%> 2 3<%@string colname="colSums2"%> 4<%@string rowname="rowSums2"%> 5<%@string fcnname="colRowSums2_subset"%> 6<%@meta title="${colname}() and ${rowname}() benchmarks on subsetted computation"%> 7<%@meta author="Henrik Bengtsson"%> 8<%@meta date="2017-03-31"%> 9 10<%@include file="${header}"%> 11 12 13 14# <%@meta name="title"%> 15 16This report benchmark the performance of <%=colname%>() and <%=rowname%>() on subsetted computation. 17 18 19<% for (mode in c("integer", "double")) { %> 20 21## Data type "<%=mode%>" 22 23### Data 24```r 25<%=withCapture({ 26<%@include file="R/random-matrices.R"%> 27data <- rmatrices(mode = mode) 28})%> 29``` 30 31### Results 32 33<% for (dataLabel in names(data)) { %> 34<% mprintf("%s: %s\n", mode, dataLabel) %> 35#### <%=dataLabel%> <%=mode%> matrix 36 37```r 38<%=withCapture({ 39X <- data[[.dataLabel.]] 40rows <- sample.int(nrow(X), size = nrow(X)*0.7) 41cols <- sample.int(ncol(X), size = ncol(X)*0.7) 42X_S <- X[rows, cols] 43gc() 44 45colStats <- microbenchmark( 46 "colSums2_X_S" = colSums2(X_S, na.rm = FALSE), 47 "colSums2(X, rows, cols)" = colSums2(X, rows = rows, cols = cols, na.rm = FALSE), 48 "colSums2(X[rows, cols])" = colSums2(X[rows, cols], na.rm = FALSE), 49 unit = "ms" 50) 51 52X <- t(X) 53X_S <- t(X_S) 54gc() 55 56rowStats <- microbenchmark( 57 "rowSums2_X_S" = rowSums2(X_S, na.rm = FALSE), 58 "rowSums2(X, cols, rows)" = rowSums2(X, rows = cols, cols = rows, na.rm = FALSE), 59 "rowSums2(X[cols, rows])" = rowSums2(X[cols, rows], na.rm = FALSE), 60 unit = "ms" 61) 62})%> 63``` 64 65<% crBenchmarkResults(colStats, rowStats, tags=c(mode, dataLabel)) %> 66 67<% } # for (dataLabel ...) %> 68 69<% } # for (mode ...) %> 70 71 72<%@include file="${footer}"%> 73