Commit 8ca797f8

8ca797f8e308Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

bench: progress display + spinel_codegen dependency

Mirror the test target's TTY progress line for benchmarks, and add spinel_codegen as a build dependency so make bench rebuilds after edits without the existence-check error path. Same TTY-only \\r\\033[K [N/total] name shape — non-TTY output unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
8ca797f8e308
Parent
2f2d97908478

MakefilemodifiedView file

@@ -226,12 +226,15 @@
226226 echo "Tests: $$pass pass, $$fail fail, $$err error"; \
227227 if [ $$fail -ne 0 ] || [ $$err -ne 0 ]; then exit 1; fi
228228
229-bench: spinel_parse$(EXE) $(SP_RT_LIB)
230- @if [ ! -f spinel_codegen$(EXE) ]; then echo "Run 'make' or 'make spinel_codegen' first"; exit 1; fi
229+bench: spinel_parse$(EXE) $(SP_RT_LIB) spinel_codegen$(EXE)
231230 @if [ -z "$(TIMEOUT_BIN)" ]; then echo "Note: no 'timeout' command found; running without time limits."; fi
232- @pass=0; fail=0; err=0; skip=0; \
231+ @total=$$(ls benchmark/*.rb | wc -l); \
232+ if [ -t 1 ]; then tty=1; else tty=0; fi; \
233+ pass=0; fail=0; err=0; skip=0; i=0; \
233234 for f in benchmark/*.rb; do \
235+ i=$$((i+1)); \
234236 bn=$$(basename "$$f" .rb); \
237+ if [ "$$tty" = 1 ]; then printf '\r\033[K [%d/%d] %s' "$$i" "$$total" "$$bn"; fi; \
235238 $(TIMEOUT10) ./spinel_parse$(EXE) "$$f" /tmp/_sp_b.ast 2>/dev/null && \
236239 $(TIMEOUT10) ./spinel_codegen$(EXE) /tmp/_sp_b.ast /tmp/_sp_b.c 2>/dev/null && \
237240 $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_b.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_b_bin$(EXE) 2>/dev/null; \
@@ -243,6 +246,7 @@
243246 ruby_rc=$$?; \
244247 fi; \
245248 if [ $$ruby_rc -eq 124 ]; then \
249+ if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
246250 echo "SKIP: $$bn (ruby timeout)"; skip=$$((skip+1)); \
247251 else \
248252 actual=$$($(TIMEOUT60) /tmp/_sp_b_bin$(EXE) 2>/dev/null); \
@@ -251,15 +255,18 @@
251255 if [ "$$expected" = "$$actual" ]; then \
252256 pass=$$((pass+1)); \
253257 else \
258+ if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
254259 echo "FAIL: $$bn"; \
255260 printf '%s\n%s\n%s\n%s\n' "--- expected ---" "$$expected" "--- actual ---" "$$actual"; \
256261 fail=$$((fail+1)); \
257262 fi; \
258263 fi; \
259264 else \
265+ if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
260266 echo "ERR: $$bn"; err=$$((err+1)); \
261267 fi; \
262268 done; \
269+ if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
263270 rm -f /tmp/_sp_b.ast /tmp/_sp_b.c /tmp/_sp_b_bin$(EXE); \
264271 echo "Benchmarks: $$pass pass, $$fail fail, $$err error, $$skip skip"; \
265272 if [ $$fail -ne 0 ] || [ $$err -ne 0 ]; then exit 1; fi