-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-readme.sh
More file actions
43 lines (34 loc) · 1.4 KB
/
update-readme.sh
File metadata and controls
43 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -euo pipefail
RESULTS_DIR="./results"
README="README.md"
# Find the most recent result file
latest=$(ls -t "${RESULTS_DIR}"/*.json 2>/dev/null | head -1)
if [[ -z "$latest" ]]; then
echo "ERROR: No JSON files found in ${RESULTS_DIR}/" >&2
exit 1
fi
echo "→ Using result file: ${latest}"
# Extract metadata
date=$(jq -r '.date' "$latest")
symfony_version=$(jq -r '.symfony_version' "$latest")
php_version=$(jq -r '.php_version' "$latest")
runs_per_version=$(jq -r '.runs_per_version' "$latest")
# Build the markdown block
new_block="_Run: ${date} — Symfony ${symfony_version} — PHP ${php_version} — ${runs_per_version} runs per version_
| Version | Median (s) | Spread |
|---------|------------|--------|"
while IFS= read -r row; do
version=$(echo "$row" | jq -r '.phparkitect_version')
median_s=$(echo "$row" | jq -r '.median_s')
spread_s=$(echo "$row" | jq -r '.spread_s')
new_block+="
| ${version} | ${median_s} | ± ${spread_s} |"
done < <(jq -c '[(.results[] | select(.phparkitect_version == "main")), (.results[] | select(.phparkitect_version != "main"))][]' "$latest")
# Replace content between markers in README
awk -v block="$new_block" '
/<!-- BENCHMARK_RESULTS_START -->/ { print; print block; skip=1; next }
/<!-- BENCHMARK_RESULTS_END -->/ { skip=0 }
!skip
' "$README" > "${README}.tmp" && mv "${README}.tmp" "$README"
echo "→ README updated."