Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement benchmarking with AirspeedVelocity.jl #119

Merged
merged 27 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
aae3be9
Setup basic benchmarking
mikeingold Oct 24, 2024
8249355
Simplify
mikeingold Oct 24, 2024
3254829
Simplify
mikeingold Oct 24, 2024
c605b13
Add LinearAlgebra dep
mikeingold Oct 24, 2024
35b55b6
Simplify scope structure for debugging
mikeingold Oct 24, 2024
50c6bc0
Add CI Action
mikeingold Oct 24, 2024
0b85443
Reorganize
mikeingold Oct 24, 2024
cde6237
Use product of test settings to construct individual tests
mikeingold Oct 24, 2024
eac0734
Formatting changes
mikeingold Oct 24, 2024
482a17e
Remove explicit LinearAlgebra ref
mikeingold Oct 24, 2024
948a12b
Combine multiple geometries into same loop
mikeingold Oct 24, 2024
793c351
Bugfix
mikeingold Oct 24, 2024
c2c1d31
Add N field for evals settings
mikeingold Oct 24, 2024
fc85db3
Add differentials tests
mikeingold Oct 25, 2024
e9d486f
Tidying
mikeingold Oct 25, 2024
473a1e2
Formatting fix
mikeingold Oct 25, 2024
f523cd0
Update .github/workflows/AirspeedVelocity.yml
JoshuaLampert Oct 25, 2024
1faea3c
Merge branch 'main' into benchmarks
JoshuaLampert Oct 25, 2024
996940f
Update .github/workflows/AirspeedVelocity.yml
JoshuaLampert Oct 25, 2024
2cc22a9
Update .github/workflows/AirspeedVelocity.yml
JoshuaLampert Oct 25, 2024
de04fe9
Use new versions of dependencies
JoshuaLampert Oct 25, 2024
9309110
Update .github/workflows/AirspeedVelocity.yml
JoshuaLampert Oct 25, 2024
605290f
Try to use benchmark script from head branch
JoshuaLampert Oct 25, 2024
e977b79
Replace deprecated `::set-output`
JoshuaLampert Oct 25, 2024
bbd80df
Apply suggestions from code review
mikeingold Oct 25, 2024
4236ac6
Drop Unitful
mikeingold Oct 25, 2024
eedc533
Split indices
mikeingold Oct 25, 2024
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
78 changes: 78 additions & 0 deletions .github/workflows/AirspeedVelocity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Benchmark a Pull Request

on:
push:
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
branches:
- main

permissions:
pull-requests: write

jobs:
generate_plots:
mikeingold marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
- uses: julia-actions/setup-julia@v1
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
with:
version: "1.8"
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
- uses: julia-actions/cache@v1
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
- name: Extract Package Name from Project.toml
id: extract-package-name
run: |
PACKAGE_NAME=$(grep "^name" Project.toml | sed 's/^name = "\(.*\)"$/\1/')
echo "::set-output name=package_name::$PACKAGE_NAME"
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
- name: Build AirspeedVelocity
env:
JULIA_NUM_THREADS: 2
run: |
# Lightweight build step, as sometimes the runner runs out of memory:
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.add(;url="https://github.com/MilesCranmer/AirspeedVelocity.jl.git")'
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.build("AirspeedVelocity")'
- name: Add ~/.julia/bin to PATH
run: |
echo "$HOME/.julia/bin" >> $GITHUB_PATH
- name: Run benchmarks
run: |
echo $PATH
ls -l ~/.julia/bin
mkdir 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.repository.default_branch}}" --output-dir=results/ --tune
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
- 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 plot as artifact
uses: actions/upload-artifact@v2
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
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' > body.md
echo '' >> body.md
echo '' >> body.md
cat table.md >> body.md
echo '' >> body.md
echo '' >> body.md
echo '### Benchmark Plots' >> body.md
echo 'A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.' >> body.md
echo 'Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).' >> body.md

- name: Find Comment
uses: peter-evans/find-comment@v2
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
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@v3
JoshuaLampert marked this conversation as resolved.
Show resolved Hide resolved
with:
comment-id: ${{ steps.fcbenchmark.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: body.md
edit-mode: replace
11 changes: 11 additions & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
BenchmarkTools = "1.5"
LinearAlgebra = "1"
Meshes = "0.50, 0.51, 0.52"
Unitful = "1.19"
49 changes: 49 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using BenchmarkTools
using LinearAlgebra
using Meshes
using MeshIntegrals
using Unitful
mikeingold marked this conversation as resolved.
Show resolved Hide resolved

const SUITE = BenchmarkGroup()

############################################################################################
# Integrals
############################################################################################

integrands = (
(name = "Scalar", f = p -> norm(to(p))),
(name = "Vector", f = p -> fill(norm(to(p)), 3))
)
rules = (
(name = "GaussLegendre", rule = GaussLegendre(100), N = 100),
(name = "GaussKronrod", rule = GaussKronrod(), N = 100),
(name = "HAdaptiveCubature", rule = HAdaptiveCubature(), N = 500)
)
geometries = (
(name = "Meshes.Segment", item = Segment(Point(0, 0, 0), Point(1, 1, 1))),
(name = "Meshes.Sphere", item = Sphere(Point(0, 0, 0), 1.0))
)

SUITE["Integrals"] = let s = BenchmarkGroup()
for (int, rule, geometry) in Iterators.product(integrands, rules, geometries)
n1, n2, N = geometry.name, "$(int.name) $(rule.name)", rule.N
s[n1, n2] = @benchmarkable integral($int.f, $geometry.item, $rule.rule) evals=N
end
s
end

############################################################################################
# Differentials
############################################################################################

sphere = geometries[2].item
differential = MeshIntegrals.differential

SUITE["Differentials"] = let s = BenchmarkGroup()
s["Jacobian"] = @benchmarkable jacobian($sphere, $(0.5, 0.5)) evals=1000
s["Differential"] = @benchmarkable differential($sphere, $(0.5, 0.5)) evals=1000
s
end

#tune!(SUITE)
#run(SUITE, verbose=true)
Loading