2025-01-12 00:52:51 +08:00

79 lines
1.3 KiB
Plaintext

<%@include file="includes/setup.md.rsp"%>
<%@string fcnname="anyMissing"%>
<% fcnname <- "<%@string name="fcnname"%>" %>
<%@meta title="${fcnname}() benchmarks"%>
<%@meta author="Henrik Bengtsson"%>
<%@meta date="2014-11-01"%>
<%@include file="${header}"%>
# <%@meta name="title"%>
This report benchmark the performance of <%=fcnname%>() against alternative methods.
## Alternative methods
* anyNA()
* any() + is.na()
as below
```r
<%=withCapture({
any_is.na <- function(x) {
any(is.na(x))
}
})%>
```
<% for (mode in c("integer", "double")) { %>
## Data type "<%=mode%>"
### Data
```r
<%=withCapture({
<%@include file="R/random-vectors.R"%>
data <- rvectors(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.]]
gc()
stats <- microbenchmark(
"anyMissing" = anyMissing(x),
"anyNA" = anyNA(x),
"any_is.na" = any_is.na(x),
unit = "ms"
)
})%>
```
<% benchmarkResults(stats, tags=c(mode, dataLabel)) %>
<% } # for (ii ...) %>
<% } # for (mode ...) %>
<%@include file="${footer}"%>
<%---------------------------------------------------------------------------
HISTORY:
2014-11-01
o Created.
---------------------------------------------------------------------------%>