diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 0000000..836f82d --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - v2* + +name: bench + +jobs: + bench: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::bench + any::nycflights13 + any::remotes + - name: install current version + run: remotes::install_github("ropensci/readODS") + shell: Rscript {0} + - name: run bench.R with the current version + run: Rscript benchmark/bench.R HEAD + - name: install PR version + run: remotes::install_local(".", upgrade = "never") + shell: Rscript {0} + - name: run bench.R with the PR version + run: Rscript benchmark/bench.R PR + - name: Print the benchmark + run: Rscript benchmark/print_bench.R diff --git a/benchmark/bench.R b/benchmark/bench.R new file mode 100644 index 0000000..092fb77 --- /dev/null +++ b/benchmark/bench.R @@ -0,0 +1,4 @@ +#!/usr/bin/env Rscript +args <- commandArgs(trailingOnly = TRUE) + +saveRDS(bench::mark(readODS::read_ods(readODS::write_ods(nycflights13::flights)), min_iterations = 3), paste0("benchmark/", args[1], "_write_ods_.RDS")) diff --git a/benchmark/print_bench.R b/benchmark/print_bench.R new file mode 100644 index 0000000..ba9d214 --- /dev/null +++ b/benchmark/print_bench.R @@ -0,0 +1,9 @@ +library(bench) +prefixes <- c("HEAD", "PR") + +## TODO: make this a GH comment + +for (prefix in prefixes) { + cat(prefix, "\n") + cat(readRDS(paste0("benchmark/", prefix, "_write_ods_.RDS"))$median, "\n") +} diff --git a/tests/testdata/multiline_cells.ods b/tests/testdata/multiline_cells.ods old mode 100755 new mode 100644