Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/Benchmark.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 14 additions & 1 deletion benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -30,6 +43,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
Loading