From 7430b120051b60f8b42e3394f59543fcf9cecf38 Mon Sep 17 00:00:00 2001 From: Toby Driscoll Date: Tue, 16 Jun 2026 14:46:28 -0400 Subject: [PATCH 1/2] change poles benchmark --- benchmark/benchmarks.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index d2f3fa1c..6c9246bb 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -30,6 +30,6 @@ end # --- pole solve --- SUITE["poles"] = BenchmarkGroup() -let r = approximate(x -> 1 / (x^2 + 0.01), unit_interval; method = Thiele) +let r = approximate(x -> 1 / sqrt(x^2 + 0.01), unit_interval; method = Thiele) SUITE["poles"]["thiele"] = @benchmarkable poles($r) end From 42ce61ff9df32d45d5ab89115b19be8371c1b621 Mon Sep 17 00:00:00 2001 From: Toby Driscoll Date: Tue, 16 Jun 2026 14:52:19 -0400 Subject: [PATCH 2/2] Add discrete-domain benchmarks and benchmark CI workflow Add an approximate_discrete group exercising Barycentric and Thiele construction over a log-clustered discrete point set, and a GitHub Actions workflow that runs AirspeedVelocity on PRs to compare against the default branch. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/Benchmark.yml | 88 +++++++++++++++++++++++++++++++++ benchmark/benchmarks.jl | 13 +++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/Benchmark.yml diff --git a/.github/workflows/Benchmark.yml b/.github/workflows/Benchmark.yml new file mode 100644 index 00000000..45eec3a8 --- /dev/null +++ b/.github/workflows/Benchmark.yml @@ -0,0 +1,88 @@ +name: Benchmark a pull request + +on: + pull_request: + branches: + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + pull-requests: write + +jobs: + benchmark: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: julia-actions/setup-julia@v2 + with: + version: "1" + - uses: julia-actions/cache@v2 + - name: Extract package name from Project.toml + id: extract-package-name + run: | + PACKAGE_NAME=$(grep "^name" Project.toml | sed 's/^name = "\(.*\)"$/\1/') + echo "package_name=$PACKAGE_NAME" >> "$GITHUB_OUTPUT" + - name: Install AirspeedVelocity + run: | + # Lightweight install, as the runner sometimes runs out of memory: + julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.add("AirspeedVelocity")' + julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.build("AirspeedVelocity")' + echo "$HOME/.julia/bin" >> "$GITHUB_PATH" + - name: Run benchmarks + run: | + mkdir -p results + benchpkg ${{ steps.extract-package-name.outputs.package_name }} \ + --rev="${{ github.event.repository.default_branch }},${{ github.event.pull_request.head.sha }}" \ + --url="${{ github.event.repository.clone_url }}" \ + --bench-on="${{ github.event.pull_request.head.sha }}" \ + --output-dir=results/ \ + --tune + - name: Create plots from benchmarks + run: | + mkdir -p plots + benchpkgplot ${{ steps.extract-package-name.outputs.package_name }} \ + --rev="${{ github.event.repository.default_branch }},${{ github.event.pull_request.head.sha }}" \ + --npart=10 --format=png --input-dir=results/ --output-dir=plots/ + - name: Upload plots as artifacts + uses: actions/upload-artifact@v4 + with: + name: plots + path: plots + - name: Create markdown table from benchmarks + run: | + benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} \ + --rev="${{ github.event.repository.default_branch }},${{ github.event.pull_request.head.sha }}" \ + --input-dir=results/ --ratio > table.md + { + echo '### Benchmark Results' + echo '' + echo 'Ratios above 1 mean this PR is slower than `${{ github.event.repository.default_branch }}`.' + echo '' + cat table.md + echo '' + echo '### Benchmark Plots' + echo 'Plots have been uploaded as an artifact to this workflow run' + echo '("Actions" -> this run -> "Artifacts" at the bottom).' + } > body.md + - name: Find existing comment + uses: peter-evans/find-comment@v3 + id: fcbenchmark + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Benchmark Results + - name: Comment on PR + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.fcbenchmark.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body-path: body.md + edit-mode: replace diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 6c9246bb..8433d29f 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -15,6 +15,19 @@ for (name, method) in (("aaa", Barycentric), ("thiele", Thiele)) g["abs_circle"] = @benchmarkable approximate(z -> abs(z - 1.0001im), $unit_circle; method = $method, allowed = true) end +# --- construction cost on a discrete point set --- +# log-clustered points near 0, matching the discrete-domain test setup +let zc = 10.0 .^ range(-15, 0, 500) + global const DISCRETE_PTS = [-reverse(zc); 0.0; zc] +end +SUITE["approximate_discrete"] = BenchmarkGroup() +for (name, method) in (("aaa", Barycentric), ("thiele", Thiele)) + g = SUITE["approximate_discrete"][name] = BenchmarkGroup() + g["tanh_steep"] = @benchmarkable approximate(x -> tanh(100x), $DISCRETE_PTS; method = $method, allowed = true) + g["abs_shift"] = @benchmarkable approximate(x -> abs(x + 0.5 + 0.01im), $DISCRETE_PTS; method = $method, allowed = true) + g["sin_recip"] = @benchmarkable approximate(x -> sin(1 / (1.05 - x)), $DISCRETE_PTS; method = $method, allowed = true) +end + # --- evaluation cost on a fixed approximant --- SUITE["evaluate"] = BenchmarkGroup() let r = approximate(x -> tanh(50x), unit_interval, method = Barycentric, allowed = true),