From 08e6272896f3ce530b7a34ad22104a7f64d16b1a Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Wed, 30 Oct 2024 16:05:04 -0400 Subject: [PATCH 1/2] Benchmarking via AirspeedVelocity --- .github/workflows/benchmark.yml | 75 +++++++++++++++++++++++++-------- benchmark/runbench.jl | 9 ---- 2 files changed, 57 insertions(+), 27 deletions(-) delete mode 100644 benchmark/runbench.jl diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 744527cf..2c171466 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,22 +11,61 @@ on: - 'docs/**' - 'examples/**' +permissions: + pull-requests: write + jobs: - Benchmark: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v2 - with: - version: 1 - - uses: julia-actions/julia-buildpkg@latest - - name: Install dependencies - run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"' - - name: Run benchmarks - run: julia -e 'using BenchmarkCI; BenchmarkCI.judge(; retune=true)' - - name: Post results - run: julia -e 'using BenchmarkCI; BenchmarkCI.postjudge()' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Print judgement - run: julia -e 'using BenchmarkCI; BenchmarkCI.displayjudgement()' \ No newline at end of file + generate_plots: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - 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 "::set-output name=package_name::$PACKAGE_NAME" + - 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 + - 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 + + - name: Find 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 \ No newline at end of file diff --git a/benchmark/runbench.jl b/benchmark/runbench.jl deleted file mode 100644 index 399c7d8b..00000000 --- a/benchmark/runbench.jl +++ /dev/null @@ -1,9 +0,0 @@ -# run this script will generate a benchmark report named report.md - -using PkgBenchmark - -current = BenchmarkConfig(juliacmd = `julia -O3`) -baseline = BenchmarkConfig(id = "master", juliacmd = `julia -O3`) -# result = benchmarkpkg("TestParticle", current; retune=true) -result = judge("TestParticle", current, baseline; retune=true) -export_markdown("report.md", result) \ No newline at end of file From b403a17340af4f4faa58fb3023f2e63f6754a6ea Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Wed, 30 Oct 2024 16:32:57 -0400 Subject: [PATCH 2/2] Rename CI --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 2c171466..f52515fe 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,4 +1,4 @@ -name: Run benchmarks +name: Benchmarks on: pull_request: