|
| 1 | +library("tidyverse") |
| 2 | +library("Rcpp") |
| 3 | +library("RcppParallel") |
| 4 | +library("RcppThread") |
| 5 | +library("ggthemes") |
| 6 | + |
| 7 | + |
| 8 | +Rcpp::sourceCpp(here::here("benchmarks/benchmarks.cpp")) |
| 9 | + |
| 10 | + |
| 11 | +wait_for <- 5 |
| 12 | + |
| 13 | +plot_df <- function(df, title = NULL) { |
| 14 | + p <- df %>% |
| 15 | + pivot_longer(-n, "call") %>% |
| 16 | + ggplot(aes(n, value, color = call)) + |
| 17 | + geom_line(size = 0.6) + |
| 18 | + expand_limits(y = 0) + |
| 19 | + labs(color = "", linetype = "") + |
| 20 | + naglr::theme_naglr(plot_title_size = 12) + |
| 21 | + theme(legend.margin = margin(1, 1, 1, 1)) + |
| 22 | + theme(legend.position = "bottom") + |
| 23 | + scale_x_log10() + |
| 24 | + ylab("speedup") + |
| 25 | + labs(title = title) |
| 26 | + print(p) |
| 27 | +} |
| 28 | + |
| 29 | + |
| 30 | +ns <- 10^(2:6) |
| 31 | +res <- benchEmpty(rev(ns), wait_for) |
| 32 | +df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 33 | +plot_df(df, "empty jobs") |
| 34 | +ggsave(here::here("benchmarks/benchEmptyThread.pdf"), width = 7.5, height = 3) |
| 35 | + |
| 36 | + |
| 37 | +ns <- 10^(2:6) |
| 38 | +res <- benchSqrt(rev(ns), wait_for) |
| 39 | +df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 40 | +plot_df(df, "1000x sqrt") |
| 41 | +ggsave(here::here("benchmarks/benchSqrt.pdf"), width = 7.5, height = 3) |
| 42 | + |
| 43 | + |
| 44 | +# ns <- 10^(2:6) |
| 45 | +# res <- benchSqrtWrite(rev(ns), wait_for) |
| 46 | +# df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 47 | +# plot_df(df, "1000x sqrt modify inplace") |
| 48 | +# ggsave(here::here("benchmarks/benchSqrtWrite.pdf"), width = 7.5, height = 3) |
| 49 | + |
| 50 | +ns <- 10^(2:4) |
| 51 | +res <- benchSqrtImbalanced(rev(ns), wait_for) |
| 52 | +df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 53 | +plot_df(df, "n times sqrt (imbalanced)") |
| 54 | +ggsave(here::here("benchmarks/benchSqrtImbalanced.pdf"), width = 7.5, height = 3) |
| 55 | + |
| 56 | +# ns <- 10^(2:4) |
| 57 | +# res <- benchSqrtWriteImbalanced(rev(ns), wait_for) |
| 58 | +# df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 59 | +# plot_df(df, "n times sqrt modify inplace (imbalanced)") |
| 60 | +# ggsave(here::here("benchmarks/benchSqrtWriteImbalanced.pdf"), width = 7.5, height = 3) |
| 61 | + |
| 62 | +ns <- 10^(2:5) |
| 63 | +res <- benchKDE(rev(ns), 100, wait_for) |
| 64 | +df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 65 | +plot_df(df, "kernel density d = 10") |
| 66 | +ggsave(here::here("benchmarks/benchKDE-10.pdf"), width = 7.5, height = 3) |
| 67 | + |
| 68 | + |
| 69 | +ns <- 10^(2:5) |
| 70 | +res <- benchKDE(rev(ns), 100, wait_for) |
| 71 | +df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 72 | +plot_df(df, "kernel density d = 100") |
| 73 | +ggsave(here::here("benchmarks/benchKDE-100.pdf"), width = 7.5, height = 3) |
| 74 | + |
| 75 | +ns <- 10^(2:4) |
| 76 | +res <- benchKendall(rev(ns), 10, wait_for) |
| 77 | +df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 78 | +plot_df(df, "Kendall matrix (unbalanced) d = 10") |
| 79 | +ggsave(here::here("benchmarks/benchKendall-10.pdf"), width = 7.5, height = 3) |
| 80 | + |
| 81 | +ns <- 10^(2:4) |
| 82 | +res <- benchKendall(rev(ns), 100, wait_for) |
| 83 | +df <- cbind(data.frame(n = rev(ns)), as.data.frame(res[, -1])) |
| 84 | +plot_df(df, "Kendall matrix (unbalanced) d = 100") |
| 85 | +ggsave(here::here("benchmarks/benchKendall-100.pdf"), width = 7.5, height = 3) |
0 commit comments