Commit 99bd2a38

99bd2a3861e8Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 99 files · ~1 modified

Description

Separate test/ and benchmark/ directories

  • test/ (57 files): language feature tests, run by make test-all
  • benchmark/ (39 files): performance benchmarks, run by make bench-verify
  • ao_render and mandel_term moved to test/ (special cases)
  • Makefile updated with bench-verify target

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

Details

Commit
99bd2a3861e8
Parent
a0a0c7dc42d7

MakefilemodifiedView file

@@ -45,14 +45,14 @@
4545
4646 # Quick test: mandelbrot only
4747 test: spinel
48- @./spinel --source=examples/bm_so_mandelbrot.rb --output=/tmp/sp_mandelbrot.c 2>/dev/null
48+ @./spinel --source=benchmark/bm_so_mandelbrot.rb --output=/tmp/sp_mandelbrot.c 2>/dev/null
4949 @$(CC) -O2 /tmp/sp_mandelbrot.c -lm -o /tmp/sp_mandelbrot 2>/dev/null
5050 @/tmp/sp_mandelbrot > /tmp/sp_m1.pbm
51- @ruby examples/bm_so_mandelbrot.rb > /tmp/sp_m2.pbm
51+ @ruby benchmark/bm_so_mandelbrot.rb > /tmp/sp_m2.pbm
5252 @diff /tmp/sp_m1.pbm /tmp/sp_m2.pbm > /dev/null && echo "test: OK (mandelbrot)" || echo "test: FAIL"
5353
5454 # Full test suite: all single-file examples
55-EXAMPLES_SIMPLE = $(filter-out examples/bm_regexp.rb examples/bm_ao_render.rb examples/bm_mandel_term.rb examples/bm_so_mandelbrot.rb, $(wildcard examples/bm_*.rb))
55+EXAMPLES_SIMPLE = $(filter-out test/bm_regexp.rb test/bm_ao_render.rb test/bm_mandel_term.rb, $(wildcard test/bm_*.rb))
5656
5757 test-all: spinel
5858 @pass=0; fail=0; skip=0; total=0; \
@@ -81,9 +81,9 @@
8181 echo ""; \
8282 echo "--- Special tests ---"; \
8383 total=$$((total + 1)); \
84- if ./spinel --source=examples/bm_so_mandelbrot.rb --output=/tmp/sp_mandelbrot.c 2>/dev/null && \
84+ if ./spinel --source=benchmark/bm_so_mandelbrot.rb --output=/tmp/sp_mandelbrot.c 2>/dev/null && \
8585 $(CC) -O2 /tmp/sp_mandelbrot.c -lm -o /tmp/sp_mandelbrot 2>/dev/null && \
86- /tmp/sp_mandelbrot > /tmp/sp_m1.pbm && ruby examples/bm_so_mandelbrot.rb > /tmp/sp_m2.pbm && \
86+ /tmp/sp_mandelbrot > /tmp/sp_m1.pbm && ruby benchmark/bm_so_mandelbrot.rb > /tmp/sp_m2.pbm && \
8787 diff /tmp/sp_m1.pbm /tmp/sp_m2.pbm > /dev/null 2>&1; then \
8888 echo " OK bm_so_mandelbrot (binary output)"; \
8989 pass=$$((pass + 1)); \
@@ -92,10 +92,10 @@
9292 fail=$$((fail + 1)); \
9393 fi; \
9494 total=$$((total + 1)); \
95- if ./spinel --source=examples/bm_regexp.rb --output=/tmp/sp_regexp.c 2>/dev/null && \
95+ if ./spinel --source=test/bm_regexp.rb --output=/tmp/sp_regexp.c 2>/dev/null && \
9696 $(CC) -O2 /tmp/sp_regexp.c /usr/lib/x86_64-linux-gnu/libonig.so.5 -lm -o /tmp/sp_regexp 2>/dev/null && \
9797 /tmp/sp_regexp > /tmp/sp_regexp_out 2>/dev/null && \
98- ruby examples/bm_regexp.rb > /tmp/sp_regexp_ref 2>/dev/null && \
98+ ruby test/bm_regexp.rb > /tmp/sp_regexp_ref 2>/dev/null && \
9999 diff /tmp/sp_regexp_out /tmp/sp_regexp_ref > /dev/null 2>&1; then \
100100 echo " OK bm_regexp (oniguruma)"; \
101101 pass=$$((pass + 1)); \
@@ -104,10 +104,10 @@
104104 skip=$$((skip + 1)); \
105105 fi; \
106106 total=$$((total + 1)); \
107- if ./spinel --source=examples/bm_require/main.rb --output=/tmp/sp_require.c 2>/dev/null && \
107+ if ./spinel --source=test/bm_require/main.rb --output=/tmp/sp_require.c 2>/dev/null && \
108108 $(CC) -O2 /tmp/sp_require.c -lm -o /tmp/sp_require 2>/dev/null && \
109109 /tmp/sp_require > /tmp/sp_require_out 2>/dev/null && \
110- ruby examples/bm_require/main.rb > /tmp/sp_require_ref 2>/dev/null && \
110+ ruby test/bm_require/main.rb > /tmp/sp_require_ref 2>/dev/null && \
111111 diff /tmp/sp_require_out /tmp/sp_require_ref > /dev/null 2>&1; then \
112112 echo " OK bm_require (multi-file)"; \
113113 pass=$$((pass + 1)); \
@@ -118,9 +118,36 @@
118118 echo ""; \
119119 echo "=== $$pass passed, $$fail failed, $$skip skipped / $$total total ==="
120120
121+# Verify benchmarks compile and run correctly
122+bench-verify: spinel
123+ @pass=0; fail=0; total=0; \
124+ echo "=== Benchmark Verification ==="; \
125+ for f in benchmark/*.rb; do \
126+ name=$$(basename $$f .rb); \
127+ total=$$((total + 1)); \
128+ if ./spinel --source=$$f --output=/tmp/sp_$${name}.c 2>/dev/null && \
129+ $(CC) -O2 -Wno-format -Wno-discarded-qualifiers -Wno-unused-value \
130+ /tmp/sp_$${name}.c -lm -o /tmp/sp_$${name} 2>/dev/null; then \
131+ if timeout 30 /tmp/sp_$${name} > /tmp/sp_$${name}_out 2>/dev/null; \
132+ ruby $$f > /tmp/sp_$${name}_ref 2>/dev/null; \
133+ diff /tmp/sp_$${name}_out /tmp/sp_$${name}_ref > /dev/null 2>&1; then \
134+ echo " OK $$name"; \
135+ pass=$$((pass + 1)); \
136+ else \
137+ echo " FAIL $$name (output differs)"; \
138+ fail=$$((fail + 1)); \
139+ fi; \
140+ else \
141+ echo " FAIL $$name (compile error)"; \
142+ fail=$$((fail + 1)); \
143+ fi; \
144+ done; \
145+ echo ""; \
146+ echo "=== $$pass passed, $$fail failed / $$total total ==="
147+
121148 # Generate C code only
122149 gen: spinel
123- ./spinel --source=examples/bm_so_mandelbrot.rb --output=mandelbrot_aot.c
150+ ./spinel --source=benchmark/bm_so_mandelbrot.rb --output=mandelbrot_aot.c
124151 @echo "Generated mandelbrot_aot.c"
125152
126153 clean: