diff --git a/.github/workflows/benchmark_pr.yml b/.github/workflows/benchmark_pr.yml index a900ac6..456451f 100644 --- a/.github/workflows/benchmark_pr.yml +++ b/.github/workflows/benchmark_pr.yml @@ -64,36 +64,44 @@ jobs: - name: Run Benchmarks run: | - echo $PATH + echo "Current PATH: $PATH" mkdir results - benchpkg --rev="${{ github.sha }},$(git rev-parse HEAD^1)" --bench-on="${{ github.sha }}" --output-dir=results/ --tune - - - name: Generate and Upload Benchmark Plots - run: | - mkdir -p plots - git fetch origin main:refs/remotes/origin/main - LAST_MAIN_COMMIT=$(git rev-parse origin/main) - CURRENT_COMMIT=$(git rev-parse HEAD) - echo "Comparing CURRENT_COMMIT ($CURRENT_COMMIT) with LAST_MAIN_COMMIT ($LAST_MAIN_COMMIT)" - benchpkgplot --rev="$LAST_MAIN_COMMIT,$CURRENT_COMMIT" --npart=10 --format=png --input-dir=results/ --output-dir=plots/ - if: always() - + git fetch origin main:refs/remotes/origin/main + if [ $(git rev-list --count HEAD) -gt 1 ]; then + PREV_COMMIT=$(git rev-parse HEAD^1) + else + PREV_COMMIT=$(git rev-parse HEAD) # Fallback to the current commit if there's no previous commit + fi + CURRENT_COMMIT=$(git rev-parse HEAD) + LAST_MAIN_COMMIT=$(git rev-parse origin/main) + echo "Benchmarking current commit ($CURRENT_COMMIT) against $PREV_COMMIT" + benchpkg --rev="$LAST_MAIN_COMMIT,$CURRENT_COMMIT" --bench-on="$CURRENT_COMMIT" --output-dir=results/ --tune + + - name: Generate and Upload Benchmark Plots + run: | + mkdir -p plots + LAST_MAIN_COMMIT=$(git rev-parse origin/main) + CURRENT_COMMIT=$(git rev-parse HEAD) + echo "Generating plots comparing CURRENT_COMMIT ($CURRENT_COMMIT) with LAST_MAIN_COMMIT ($LAST_MAIN_COMMIT)" + benchpkgplot --rev="$LAST_MAIN_COMMIT,$CURRENT_COMMIT" --npart=10 --format=png --input-dir=results/ --output-dir=plots/ + if: always() + - name: Upload Plots as Artifacts uses: actions/upload-artifact@v4 with: name: benchmark-plots path: plots - + - name: Create and Display Benchmark Table run: | - git fetch origin main:refs/remotes/origin/main # Ensures you have the latest main branch + mkdir -p results if [ $(git rev-list --count HEAD) -gt 1 ]; then PREV_COMMIT=$(git rev-parse HEAD^1) else - PREV_COMMIT=$(git rev-parse HEAD) # Fallback to the current commit if there's no previous commit + PREV_COMMIT=$(git rev-parse HEAD) # Use the current commit as a fallback fi - LAST_MAIN_COMMIT=$(git rev-parse origin/main) # Ensures comparison against the latest commit in main - echo "Using revisions: $LAST_MAIN_COMMIT and $PREV_COMMIT for benchmark comparison." + LAST_MAIN_COMMIT=$(git rev-parse origin/main) # Fetch the latest commit from main for comparison + echo "Creating benchmark table comparing CURRENT_COMMIT with LAST_MAIN_COMMIT" benchpkgtable --rev="$LAST_MAIN_COMMIT,$PREV_COMMIT" --input-dir=results/ > table.md echo '### Benchmark Results' > body.md cat table.md >> body.md @@ -101,7 +109,7 @@ jobs: echo 'A plot of the benchmark results has been uploaded as an artifact to this workflow run.' >> body.md cat body.md # Print the markdown table to the log for review. if: always() - + - name: Upload Benchmark Results Table uses: actions/upload-artifact@v4 with: