/
benchmarks.R
88 lines (72 loc) · 3.04 KB
/
benchmarks.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
library(dplyr)
rdf_vec <- as.matrix(data.table::fread(
"inst/extdata/Scenario/ISM1988_2014,2007Dems,IG,Most/KeySlots.rdf",
sep = '\t',
header = FALSE,
data.table = FALSE
))
rdf <- read_rdf("inst/extdata/Scenario/ISM1988_2014,2007Dems,IG,Most/KeySlots.rdf")
std_cols <- c("Timestep", "TraceNumber", "ObjectSlot", "Value")
mb <- microbenchmark::microbenchmark(
"c++" = RWDataPlyr:::rdf_to_rwtbl_cpp(rdf_vec, keep_cols = std_cols, add_ym = FALSE) %>% tibble::as_tibble(),
"c++ old" = RWDataPlyr:::rdf_to_rwtbl_cpp_old(rdf_vec) %>% tibble::as_tibble(),
"R" = rdf_to_rwtbl(rdf, keep_cols = TRUE),
times = 50
)
mb2<- microbenchmark::microbenchmark(
"c++" = RWDataPlyr:::rdf_to_rwtbl_cpp(rdf_vec, scenario = "haha", keep_cols = std_cols) %>% tibble::as_tibble(),
"c++ old" = RWDataPlyr:::rdf_to_rwtbl_cpp_old(rdf_vec) %>% tibble::as_tibble(),
"R" = rdf_to_rwtbl(rdf, keep_cols = TRUE, scenario = "haha"),
times = 50
)
t1 <- RWDataPlyr:::rdf_to_rwtbl_cpp(rdf_vec, scenario = "haha", keep_cols = std_cols) %>% tibble::as_tibble()
t2 <- rdf_to_rwtbl(rdf, keep_cols = TRUE, scenario = "haha")
# --------------------------
sal <- slot_agg_list(
matrix(
c("KeySlots.rdf", "Mead.Pool Elevation", "EOCY", NA, "meadPe"),
nrow = 1
)
)
rwa <- rwd_agg(data.frame(
file = "KeySlots.rdf",
slot = "Mead.Pool Elevation",
period = "December",
summary = NA,
eval = NA,
t_s = NA,
variable = "meadPe",
stringsAsFactors = FALSE
))
scen <- "ISM1988_2014,2007Dems,IG,Most"
spath <- system.file("extdata", "Scenario/", package = "RWDataPlyr")
mb <- microbenchmark::microbenchmark(
"rdfagg cpp" = rdf_aggregate(rwa, file.path(spath, scen), cpp = TRUE),
"rdfagg old" = rdf_aggregate(rwa, file.path(spath, scen), cpp = FALSE),
"scenagg cpp" = rw_scen_aggregate(scen, rwa, spath, scen_names = scen, cpp = TRUE),
"scenagg old" = rw_scen_aggregate(scen, rwa, spath, scen_names = scen, cpp = FALSE),
"getallscens" = getDataForAllScens(scen, scen, sal, spath, "tmp.feather"),
times = 50
)
rwa <- read_rwd_agg(
system.file(
"extdata/rwd_agg_files/passing_aggs.csv",
package = "RWDataPlyr"
)
)
sal <- slot_agg_list(matrix(c(
"KeySlots.rdf", "Mead.Pool Elevation", "AnnMinLTE", 1e+03, "peLt1000",
"KeySlots.rdf", "Mead.Pool Elevation", "EOCY", NA, "peEocy",
"KeySlots.rdf", "Powell.Outflow", "BOCY", NA, "julyRel",
"KeySlots.rdf", "Powell.Outflow", "WYMaxLTE", 400000, "pMonthlyGt400k",
"KeySlots.rdf", "Powell.Outflow", "AnnualSum", 1e-03, "pwyRel",
"SystemConditions.rdf", "SummaryOutputData.LBShortageConditions", "AnnualRaw", NA, "short",
"SystemConditions.rdf", "SummaryOutputData.UpperBalancingAbove823", "AnnualRaw", NA, "ueb823"
), nrow = 7, byrow = TRUE))
scens <- c("ISM1988_2014,2007Dems,IG,Most", "ISM1988_2014,2007Dems,IG,2002")
mb <- microbenchmark::microbenchmark(
"scenagg cpp" = rw_scen_aggregate(scen, rwa, spath, scen_names = scen, cpp = TRUE),
"scenagg old" = rw_scen_aggregate(scen, rwa, spath, scen_names = scen, cpp = FALSE),
"getallscens" = getDataForAllScens(scen, scen, sal, spath, "tmp.feather"),
times = 50
)