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:
FIZZBENCH
: FIZZBENCH 0 100000 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
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
sd/star_forth_test_suite.1773386229.txt.gz · Last modified: by appledog
