Skip to content

Commit 57a4a80

Browse files
authored
Modify benchmark workflow for map preview and checkout
Updated the benchmark workflow to use actions/checkout@v5 and added steps to check for and upload a map preview artifact.
1 parent 0c47e36 commit 57a4a80

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

.github/workflows/pr-benchmark.yml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout code
23-
uses: actions/checkout@v6
23+
uses: actions/checkout@v5
2424

2525
- name: Set up Rust
2626
uses: dtolnay/rust-toolchain@v1
@@ -43,7 +43,7 @@ jobs:
4343
- name: Run benchmark command with memory tracking
4444
id: benchmark
4545
run: |
46-
/usr/bin/time -v ./target/release/arnis --path="./world" --terrain --bbox="48.125768 11.552296 48.148565 11.593838" 2> benchmark_log.txt
46+
/usr/bin/time -v ./target/release/arnis --path="./world" --terrain --generate-map --bbox="48.125768 11.552296 48.148565 11.593838" 2> benchmark_log.txt
4747
grep "Maximum resident set size" benchmark_log.txt | awk '{print $6}' > peak_mem_kb.txt
4848
peak_kb=$(cat peak_mem_kb.txt)
4949
peak_mb=$((peak_kb / 1024))
@@ -57,6 +57,25 @@ jobs:
5757
duration=$((end_time - start_time))
5858
echo "duration=$duration" >> $GITHUB_OUTPUT
5959
60+
- name: Check for map preview
61+
id: map_check
62+
run: |
63+
if [ -f "./world/arnis_world_map.png" ]; then
64+
echo "Map preview generated successfully"
65+
echo "map_exists=true" >> $GITHUB_OUTPUT
66+
else
67+
echo "Map preview not found"
68+
echo "map_exists=false" >> $GITHUB_OUTPUT
69+
fi
70+
71+
- name: Upload map preview as artifact
72+
if: steps.map_check.outputs.map_exists == 'true'
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: world-map-preview
76+
path: ./world/arnis_world_map.png
77+
retention-days: 60
78+
6079
- name: Format duration and generate summary
6180
id: comment_body
6281
run: |
@@ -87,17 +106,28 @@ jobs:
87106
mem_annotation=" (↗ ${mem_percent}% more)"
88107
fi
89108
109+
# Get current timestamp
110+
benchmark_time=$(date -u "+%Y-%m-%d %H:%M:%S UTC")
111+
run_url="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
112+
90113
{
91114
echo "summary<<EOF"
92-
echo "⏱️ Benchmark run finished in **${minutes}m ${seconds}s**"
93-
echo "🧠 Peak memory usage: **${peak_mem} MB**${mem_annotation}"
115+
echo "## ⏱️ Benchmark Results"
94116
echo ""
95-
echo "📈 Compared against baseline: **${baseline_time}s**"
96-
echo "🧮 Delta: **${diff}s**"
97-
echo "🔢 Commit: [\`${GITHUB_SHA:0:7}\`](https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA})"
117+
echo "| Metric | Value |"
118+
echo "|--------|-------|"
119+
echo "| Duration | **${minutes}m ${seconds}s** |"
120+
echo "| Peak Memory | **${peak_mem} MB**${mem_annotation} |"
121+
echo "| Baseline | **${baseline_time}s** |"
122+
echo "| Delta | **${diff}s** |"
123+
echo "| Commit | [\`${GITHUB_SHA:0:7}\`](https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}) |"
98124
echo ""
99125
echo "${verdict}"
100126
echo ""
127+
echo "---"
128+
echo ""
129+
echo "📅 **Last benchmark:** ${benchmark_time} | 📥 [Download generated world map](${run_url}#artifacts)"
130+
echo ""
101131
echo "_You can retrigger the benchmark by commenting \`retrigger-benchmark\`._"
102132
echo "EOF"
103133
} >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)