Skip to content

Commit

Permalink
feat(benchmark): Generalise workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusSkytte committed Mar 21, 2024
1 parent 549c174 commit 2cb613b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
BACKEND: SQLite
BACKEND_DRV: RSQLite::SQLite
BACKEND_ARGS: 'list(dbname = file.path(tempdir(), "SQLite.SQLite"))'
run: source("./data-raw/benchmark_update_snapshot.R", echo=TRUE)
run: source("./data-raw/benchmark.R", echo=TRUE)
shell: Rscript {0}

- name: Run benchmark (DuckDB)
Expand All @@ -62,15 +62,15 @@ jobs:
BACKEND: DuckDB
BACKEND_DRV: duckdb::duckdb
BACKEND_ARGS: 'list(dbdir = file.path(tempdir(), "DuckDB.duckdb"))'
run: source("./data-raw/benchmark_update_snapshot.R", echo=TRUE)
run: source("./data-raw/benchmark.R", echo=TRUE)
shell: Rscript {0}

- name: Run benchmark (PostgreSQL)
if: always()
env:
BACKEND: PostgreSQL
BACKEND_DRV: RPostgres::Postgres
run: source("./data-raw/benchmark_update_snapshot.R", echo=TRUE)
run: source("./data-raw/benchmark.R", echo=TRUE)
shell: Rscript {0}

- name: Run benchmark (MSSQL)
Expand All @@ -88,7 +88,7 @@ jobs:
"PWD": "dbatools.I0"
}
}
run: source("./data-raw/benchmark_update_snapshot.R", echo=TRUE)
run: source("./data-raw/benchmark.R", echo=TRUE)
shell: Rscript {0}

- name: Display structure of benchmark files
Expand All @@ -100,7 +100,7 @@ jobs:
run: |
benchmark_files <- list.files(
"data",
pattern = "update_snapshot_benchmark_",
pattern = "^benchmark-",
full.names = TRUE,
recursive = TRUE
)
Expand All @@ -127,7 +127,7 @@ jobs:
ggplot2::aes(x = version, y = time / 1e9)
) +
ggplot2::geom_boxplot() +
ggplot2::facet_grid(~ expr) +
ggplot2::facet_grid(function ~ expr) +
ggplot2::labs(x = "Codebase version", y = "Time (s)") +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, hjust = 1, vjust = 0.5))
Expand Down
4 changes: 2 additions & 2 deletions data-raw/benchmark_update_snapshot.R → data-raw/benchmark.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ for (version in c("CRAN", "main", "branch")) {
names(benchmark_exprs) <- names(conns)[[1]]

update_snapshot_benchmark <- microbenchmark::microbenchmark(list = benchmark_exprs, times = 25) |>
dplyr::mutate("version" = !!ifelse(version == "branch", branch, version))
dplyr::mutate("function" = "update_snapshot", "version" = !!ifelse(version == "branch", branch, version))


dir.create("data", showWarnings = FALSE)
saveRDS(update_snapshot_benchmark, glue::glue("data/update_snapshot_benchmark_{names(conns)[[1]]}_{version}.rds"))
saveRDS(update_snapshot_benchmark, glue::glue("data/benchmark-update_snapshot_{names(conns)[[1]]}_{version}.rds"))

# Clean up
purrr::walk(conns, ~ DBI::dbDisconnect(., shutdown = TRUE))
Expand Down

0 comments on commit 2cb613b

Please sign in to comment.