-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.duckplyr.R
56 lines (53 loc) · 1.44 KB
/
run.duckplyr.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
library(ggplot2)
library(tibble)
library(dplyr)
library(patchwork)
library(duckplyr)
threads <- 8
duckdb_set_threads <- \(conn) {
dbExecute(conn = conn, paste0("PRAGMA threads='", threads, "'"))
}
run <- function() {
all <- bench::press(
n = c("1e6", "1e7", "1e8", "1e9"),
{
file_name <- paste0("measurements.", n, ".csv")
res <- bench::mark(
duckplyr_df_from_csv = {
print("duckplyr_df_from_csv")
df <- duckplyr::duckplyr_df_from_csv(file_name) |>
group_by(state) |>
summarize(
state_min = min(measurement),
state_sum = sum(measurement),
state_n = n(),
state_max = max(measurement)
) |>
mutate(state_mean = state_sum / state_n) |>
select(state, state_min, state_mean, state_max) |>
collect()
print(df)
},
memory = FALSE,
filter_gc = FALSE,
min_iterations = 10,
check = FALSE
)
print(res)
p <- ggplot2::autoplot(res, type = "violin") +
labs(title = paste(n, "rows"))
pdf(NULL)
ggsave(paste0(Sys.Date(), "_", n, "_duckplyr_rows.png"), plot = p)
res
}
)
print(all)
return(all)
}
results <- run()
p <- results %>%
ggplot2::autoplot(type = "violin") + labs(title = paste(n, "rows"))
pdf(NULL)
ggsave(paste0(Sys.Date(), "_all_duckplyr_rows.png"), plot = p)
BRRR::skrrrahh(13)
sessionInfo()