sd:star_forth_test_suite
This is an old revision of the document!
Table of Contents
Star Forth Test Suite
Current version: 1.0
| Version | Pass/Fail | Test | Expected Results |
|---|---|---|---|
| 1.0 260313 | PASS | signed >-3 0 > . | 0 |
| 1.0 260313 | PASS | : ;: TEST 42 . ; | 42 |
| 1.0 260313 | PASS | IF/THEN: SIGN DUP 0 > IF 43 EMIT THEN . ;5 SIGN-3 SIGN0 SIGN | +5-30 |
| 1.0 260313 | PASS | DO/LOOP/I: TENS 10 0 DO I . LOOP ;TENS | 0 1 2 3 4 5 6 7 8 9 |
| 1.0 260313 | PASS | BEGIN/UNTIL: COUNT3 3 BEGIN DUP . 1 - DUP 0 = UNTIL DROP ;COUNT3 | 3 2 1 |
| 1.0 260313 | PASS | BEGIN/WHILE: COUNTDOWN BEGIN DUP WHILE DUP . 1 - REPEAT DROP ;5 COUNTDOWN0 COUNTDOWN | 5 4 3 2 10 |
| 1.0 260313 | PASS | HERE . | $030800 |
| 1.0 260313 | PASS | HEX $030800 @ . | 0 |
| 1.0 260313 | PASS | $030800 C@ . | 0 |
| 1.0 260313 | PASS | 42 HERE ! HERE @ . | 42 |
| 1.0 260313 | PASS | : GREET .“ Hello, World!” CR ;GREET | Hello, world! |
| 1.0 260313 | PASS | : FIZZBUZZ 21 1 DO I 15 MOD 0 = IF .“ FizzBuzz” ELSE I 3 MOD 0 = IF .“ Fizz” ELSE I 5 MOD 0 = IF .“ Buzz” ELSE I . THEN THEN THEN CR LOOP ; | not shown (but it works) |
| 1.0 260313 | PASS | : SIMPLE 500000 0 DO LOOP ;SIMPLE | ~6 seconds (170,000 w/s) at 4MHz |
| 1.0 260313 | PASS | : BENCH 500000 0 DO I DUP * DROP LOOP ;BENCH | 22 seconds (140,000 w/s) at 4Mhz |
Benchmarking
The SIMPLE and BENCH tests indicate SD/FORTH is:
- 75x faster than BASIC (1,800 lines/sec) × ~5 ops/line ≈ 9,000 ops/sec)
- 5x to 7x faster than a real C64 running DurexForth (~25,000 words/sec)
- Comparable to a 4 MHz Z80 running Forth850 or an 8MHz Z80B running CamelForth.
However, this is an upper end. The following MUL and DIV heavy benchmarks operate a bit slower. Here's a summary of the followinf programs:
| Benchmark | Words/Sec. | Notes |
| Bare Loop | 170,000 | Only dispatch overhead |
| DUP * DROP | 136,000 | Multiply, Stack Ops |
| FizzBench | 97,000 | 3x MOD, branches |
| Mixed +-*/ | 90,000 | Division, Heavy Stack |
| Mixed no DIV | 100,000 | Same as above minus the DIV |
| Mixed ADD only | 120,000 | Same as above but no MUL too. |
The estimate is that 70% overhead is dispatch; the system wants to run at over 150,000 words/sec, but gets constrained down to 90-100k words/sec on MUL and DIV heavy code. This is not unusual, and is infact a great sign; this is a very fast FORTH all things considered.
FIZZBENCH
: FIZZBENCH 0 10000 0
DO I 15 MOD 0 = IF 1 + ELSE
I 3 MOD 0 = IF 1 + ELSE
I 5 MOD 0 = IF 1 + THEN
THEN
THEN
LOOP
;
: FB10 10 0 DO FIZZBENCH LOOP . ." hits" CR ;
FB10
This executes in 18.5 seconds, indicating 97,000 words/sec.
BENCH-ARITH
: ARITH ( n -- n )
DUP 42 +
DUP 7 -
DUP 3 *
DUP 2 /
DROP DROP DROP DROP ;
: BENCH-ARITH ( -- )
." Arithmetic benchmark" CR
100000 0 DO
I ARITH DROP
LOOP
." Done" CR ;
BENCH-ARITH
Same without DIV:
: ARITH3 ( n -- n )
DUP 42 +
DUP 7 -
DUP 3 *
DROP DROP DROP ;
: BENCH3 ( -- )
." Add/Sub/Mul benchmark" CR
100000 0 DO
I ARITH3 DROP
LOOP
." Done" CR ;
BENCH3
sd/star_forth_test_suite.1773387190.txt.gz · Last modified: by appledog
