From 2cb613b8538a265608c8f88384c1da57777e49a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Skytte=20Randl=C3=B8v?= Date: Thu, 21 Mar 2024 10:16:32 +0100 Subject: [PATCH] feat(benchmark): Generalise workflow --- .github/workflows/benchmark.yaml | 12 ++++++------ .../{benchmark_update_snapshot.R => benchmark.R} | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) rename data-raw/{benchmark_update_snapshot.R => benchmark.R} (94%) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 2f0ae1af..906348b3 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -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) @@ -62,7 +62,7 @@ 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) @@ -70,7 +70,7 @@ jobs: 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) @@ -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 @@ -100,7 +100,7 @@ jobs: run: | benchmark_files <- list.files( "data", - pattern = "update_snapshot_benchmark_", + pattern = "^benchmark-", full.names = TRUE, recursive = TRUE ) @@ -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)) diff --git a/data-raw/benchmark_update_snapshot.R b/data-raw/benchmark.R similarity index 94% rename from data-raw/benchmark_update_snapshot.R rename to data-raw/benchmark.R index 25a74f43..67cffe3c 100644 --- a/data-raw/benchmark_update_snapshot.R +++ b/data-raw/benchmark.R @@ -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))