@@ -9,10 +9,7 @@ permissions:
99
1010jobs :
1111 benchmark :
12- strategy :
13- matrix :
14- os : [ubuntu-latest, windows-latest]
15- runs-on : ${{ matrix.os }}
12+ runs-on : ubuntu-latest
1613 steps :
1714 - uses : actions/checkout@v6
1815
2825 with :
2926 python-version : ' 3.13'
3027
31- - name : Install system dependencies (Ubuntu)
32- if : runner.os == 'Linux'
28+ - name : Install system dependencies
3329 run : sudo apt-get update && sudo apt-get install -y libcairo2-dev
3430
3531 - name : Install Python dependencies
@@ -46,41 +42,39 @@ jobs:
4642
4743 snippet_count=$(find content \( -name '*.json' -o -name '*.yaml' -o -name '*.yml' \) -not -name 'template.*' | wc -l | tr -d ' ')
4844 java_ver=$(java -version 2>&1 | head -1 | sed 's/.*"\(.*\)".*/\1/')
49- os_name="${{ matrix.os }} "
45+ os_name="ubuntu-latest "
5046
51- # Timing helper using bash TIMEFORMAT
47+ # Nanosecond timestamp helper
48+ _now() { python3 -c "import time; print(int(time.time()*1e9))"; }
49+
50+ # Timing helper — returns seconds or "FAIL"
5251 measure() {
53- TIMEFORMAT='%R'
54- local t ec
55- t=$( { time "$@" > /dev/null 2>&1; ec=$?; } 2>&1 )
56- if [[ ${ec:-1} -ne 0 ]]; then
57- # Re-check: the subshell exit code isn't always captured
58- if ! "$@" > /dev/null 2>&1; then
59- echo "FAIL"
60- return 1
61- fi
52+ local start end
53+ start=$(_now)
54+ if "$@" > /dev/null 2>&1; then
55+ end=$(_now)
56+ awk "BEGIN {printf \"%.2f\", ($end - $start) / 1000000000}"
57+ else
58+ echo "FAIL"
6259 fi
63- echo "$t"
6460 }
6561
6662 avg_runs() {
6763 local n="$1"; shift
68- local sum=0 failures =0
64+ local sum=0 success =0
6965 for ((i = 1; i <= n; i++)); do
7066 local t
71- t=$(measure "$@") || true
72- if [[ "$t" = = "FAIL" ]]; then
73- ((failures++)) || true
74- continue
67+ t=$(measure "$@")
68+ if [[ "$t" ! = "FAIL" ]]; then
69+ sum=$(awk "BEGIN {print $sum + $t}")
70+ success=$((success + 1))
7571 fi
76- sum=$(awk "BEGIN {print $sum + $t}")
7772 done
78- local success=$((n - failures))
7973 if [[ $success -eq 0 ]]; then
8074 echo "FAIL"
81- return 0
75+ else
76+ awk "BEGIN {printf \"%.2f\", $sum / $success}"
8277 fi
83- awk "BEGIN {printf \"%.2f\", $sum / $success}"
8478 }
8579
8680 echo "Running benchmark on $os_name (Java $java_ver, $snippet_count snippets)..."
@@ -164,10 +158,7 @@ jobs:
164158 # Python and JBang start with zero caches, just like real CI.
165159 # ---------------------------------------------------------------------------
166160 build-jar :
167- strategy :
168- matrix :
169- os : [ubuntu-latest, windows-latest]
170- runs-on : ${{ matrix.os }}
161+ runs-on : ubuntu-latest
171162 steps :
172163 - uses : actions/checkout@v6
173164
@@ -188,7 +179,7 @@ jobs:
188179 - name : Upload JAR and AOT
189180 uses : actions/upload-artifact@v4
190181 with :
191- name : generator-${{ matrix.os }}
182+ name : generator
192183 path : |
193184 html-generators/generate.jar
194185 html-generators/generate.aot
@@ -197,10 +188,7 @@ jobs:
197188
198189 ci-cold-start :
199190 needs : build-jar
200- strategy :
201- matrix :
202- os : [ubuntu-latest, windows-latest]
203- runs-on : ${{ matrix.os }}
191+ runs-on : ubuntu-latest
204192 steps :
205193 - uses : actions/checkout@v6
206194
@@ -214,8 +202,7 @@ jobs:
214202 with :
215203 python-version : ' 3.13'
216204
217- - name : Install system dependencies (Ubuntu)
218- if : runner.os == 'Linux'
205+ - name : Install system dependencies
219206 run : sudo apt-get update && sudo apt-get install -y libcairo2-dev
220207
221208 - name : Install Python dependencies
@@ -224,27 +211,27 @@ jobs:
224211 - name : Download JAR and AOT
225212 uses : actions/download-artifact@v4
226213 with :
227- name : generator-${{ matrix.os }}
214+ name : generator
228215 path : html-generators
229216
230217 - name : CI cold-start benchmark
231218 shell : bash
232219 run : |
233- os_name="${{ matrix.os }} "
220+ os_name="ubuntu-latest "
234221 java_ver=$(java -version 2>&1 | head -1 | sed 's/.*"\(.*\)".*/\1/')
235222 snippet_count=$(find content \( -name '*.json' -o -name '*.yaml' -o -name '*.yml' \) -not -name 'template.*' | wc -l | tr -d ' ')
236223
224+ _now() { python3 -c "import time; print(int(time.time()*1e9))"; }
225+
237226 measure() {
238- TIMEFORMAT='%R'
239- local t ec
240- t=$( { time "$@" > /dev/null 2>&1; ec=$?; } 2>&1 )
241- if [[ ${ec:-1} -ne 0 ]]; then
242- if ! "$@" > /dev/null 2>&1; then
243- echo "FAIL"
244- return 1
245- fi
227+ local start end
228+ start=$(_now)
229+ if "$@" > /dev/null 2>&1; then
230+ end=$(_now)
231+ awk "BEGIN {printf \"%.2f\", ($end - $start) / 1000000000}"
232+ else
233+ echo "FAIL"
246234 fi
247- echo "$t"
248235 }
249236
250237 # Everything is cold: no __pycache__, no JBang cache, fresh JVM
0 commit comments