Download Package `dplyr`
Transcript
8
bench_compare
ref
For checking, an data frame to test results against. If not supplied, defaults to
the results from the first src.
compare
A function used to compare the results. Defaults to equal_data_frame which
ignores the order of rows and columns.
...
For compare_tbls: additional parameters passed on the compare function
For bench_tbls: additional benchmarks to run.
Value
eval_tbls: a list of data frames.
compare_tbls: an invisible TRUE on success, otherwise an error is thrown.
bench_tbls: an object of class microbenchmark
See Also
src_local for working with local data
Examples
## Not run:
if (require("microbenchmark") && has_lahman()) {
lahman_local <- lahman_srcs("df", "dt")
teams <- lapply(lahman_local, function(x) x %>% tbl("Teams"))
compare_tbls(teams, function(x) x %>% filter(yearID == 2010))
bench_tbls(teams, function(x) x %>% filter(yearID == 2010))
# You can also supply arbitrary
# if there are other operations
bench_tbls(teams, function(x) x
base = subset(Lahman::Teams,
additional arguments to bench_tbls
you'd like to compare.
%>% filter(yearID == 2010),
yearID == 2010))
# A more complicated example using multiple tables
setup <- function(src) {
list(
src %>% tbl("Batting") %>% filter(stint == 1) %>% select(playerID:H),
src %>% tbl("Master") %>% select(playerID, birthYear)
)
}
two_tables <- lapply(lahman_local, setup)
op <- function(tbls) {
semi_join(tbls[[1]], tbls[[2]], by = "playerID")
}
# compare_tbls(two_tables, op)
bench_tbls(two_tables, op, times = 2)
}
## End(Not run)