Skip to content

Commit

Permalink
feat(benchmarks): Allow backends to be excluded
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusSkytte committed Oct 21, 2024
1 parent a8a5498 commit 4aad419
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
38 changes: 17 additions & 21 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
on:
workflow_dispatch
workflow_call:
inputs:
backend_exclude:
type: string
default: ''


name: "⏱️ Benchmark"
jobs:
benchmark:
name: "⏱️ Benchmark"
runs-on: ubuntu-latest

concurrency:
Expand All @@ -31,18 +34,18 @@ jobs:

steps:
- name: Install a SQL Server suite of tools
if: ${{ !contains(inputs.backend_exclude, 'mssql') }}
uses: potatoqualitee/[email protected]
with:
install: sqlengine, sqlpackage, sqlclient
show-log: true

- name: Configure SQL server
if: ${{ !contains(inputs.backend_exclude, 'mssql') }}
run: |
set -o xtrace
sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -Q "ALTER LOGIN SA WITH DEFAULT_DATABASE = master;"
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -54,8 +57,6 @@ jobs:
git config --local user.email "[email protected]"
git switch ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
Expand All @@ -64,43 +65,41 @@ jobs:
with:
extra-packages: any::devtools


- name: Delete previous benchmark files
if: always()
run: rm -rf inst/extdata/benchmark-*.rds



- name: Get SQLite version
if: ${{ !contains(inputs.backend_exclude, 'sqlite') }}
run: |
version=$(Rscript -e "cat(DBI::dbGetQuery(DBI::dbConnect(RSQLite::SQLite()), 'SELECT sqlite_version();')[[1]])")
echo "SQLITE_VERSION=SQLite v$version" >> $GITHUB_ENV
- name: Get DuckDB version
if: ${{ !contains(inputs.backend_exclude, 'duckdb') }}
run: |
version=$(Rscript -e "conn <- DBI::dbConnect(duckdb::duckdb()); cat(DBI::dbGetQuery(conn, 'SELECT version();')[[1]]); DBI::dbDisconnect(conn, shutdown = TRUE)")
echo "DUCKDB_VERSION=DuckDB $version" >> $GITHUB_ENV
- name: Get PostgreSQL version
if: ${{ !contains(inputs.backend_exclude, 'postgres') }}
run: |
version=$(psql --version | awk '{print $3}')
echo "POSTGRES_VERSION=PostgreSQL v$version" >> $GITHUB_ENV
- name: Get SQL Server version
if: ${{ !contains(inputs.backend_exclude, 'mssql') }}
run: |
version=$(sqlcmd -S localhost -U SA -P dbatools.I0 -Q "SET NOCOUNT ON; SELECT SERVERPROPERTY('productversion') AS version" -h -1 -W -b)
echo "SQL_SERVER_VERSION=SQL Server v$version" >> $GITHUB_ENV
- name: Install libraries to benchmark
if: always()
run: source("./data-raw/benchmark.R", echo=TRUE)
shell: Rscript {0}



- name: Run benchmark (${{ env.SQLITE_VERSION }})
if: always()
if: ${{ always() && !contains(inputs.backend_exclude, 'sqlite') }}
env:
BACKEND: ${{ env.SQLITE_VERSION }}
BACKEND_DRV: RSQLite::SQLite
Expand All @@ -109,7 +108,7 @@ jobs:
shell: Rscript {0}

- name: Run benchmark (${{ env.DUCKDB_VERSION }})
if: always()
if: ${{ always() && !contains(inputs.backend_exclude, 'duckdb') }}
env:
BACKEND: ${{ env.DUCKDB_VERSION }}
BACKEND_DRV: duckdb::duckdb
Expand All @@ -118,15 +117,15 @@ jobs:
shell: Rscript {0}

- name: Run benchmark (${{ env.POSTGRES_VERSION }})
if: always()
if: ${{ always() && !contains(inputs.backend_exclude, 'postgres') }}
env:
BACKEND: ${{ env.POSTGRES_VERSION }}
BACKEND_DRV: RPostgres::Postgres
run: source("./data-raw/benchmark.R", echo=TRUE)
shell: Rscript {0}

- name: Run benchmark (${{ env.SQL_SERVER_VERSION }})
if: always()
if: ${{ always() && !contains(inputs.backend_exclude, 'mssql') }}
env:
BACKEND: ${{ env.SQL_SERVER_VERSION }}
BACKEND_DRV: odbc::odbc
Expand All @@ -143,8 +142,6 @@ jobs:
run: source("./data-raw/benchmark.R", echo=TRUE)
shell: Rscript {0}



- name: Display structure of benchmark files
if: always()
run: ls -R inst/extdata
Expand Down Expand Up @@ -177,7 +174,6 @@ jobs:
saveRDS(benchmarks, file.path("inst", "extdata", "benchmarks.rds"))
file.remove(benchmark_files)
# Add note slow backends
slow_backends <- benchmarks |>
dplyr::distinct(.data$database, .data$n) |>
Expand All @@ -187,7 +183,6 @@ jobs:
benchmarks <- benchmarks |>
dplyr::mutate("database" = paste0(database, ifelse(database %in% slow_backends, "*", "")))
# Mean and standard deviation (see ggplot2::mean_se())
mean_sd <- function(x) {
mu <- mean(x)
Expand Down Expand Up @@ -229,6 +224,7 @@ jobs:
path: benchmarks.pdf

- name: Commit and push changes
if: always()
run: |
git remote set-url origin https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git
git stash --include-untracked
Expand Down
4 changes: 4 additions & 0 deletions workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,7 @@ Runs `data-raw/benchmarks.R` across all test backends and compiles benchmarks to

#### Outcome
Benchmark data compiled to `inst/extdata/benchmarks.rds`.

| Arguments | Description | Default | Example |
|----------------------|----------------------------------------------------------|-------------|---------------|
| `backend_exclude` | Data base backends to skip (optional) | '' | postgres |
11 changes: 11 additions & 0 deletions workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
on:
workflow_dispatch

name: Benchmark

jobs:
document:
uses: ssi-dk/AEF-DDF/.github/workflows/benchmark.yaml@main
secrets: inherit
with:
backend_exclude: ""

0 comments on commit 4aad419

Please sign in to comment.