-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathblock-200.fth
32 lines (29 loc) · 1.19 KB
/
block-200.fth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
( benchmarks / tests )
find bm1 loaded?
test-if'n' swapifdrop 'y'thenemit '.' emit ;
if-elseifz" yes" else z" no"thenztype '.' emit ;
cr 0 test-if 1 test-if see test-if cr
cr 0 if-else 1 if-else see if-else cr
..dup . ;
[[ cr 5 for i . ." -- " 4 for i . next ." -- " next ]]
[[ cr 10 begin .. 1- dup while drop ]]
[[ cr 0 begin .. 1+ dup 10 = until drop ]]
elapsedtimer swap - ." (%d usec)" ; mil1000 dup * * ;
t01 drop ; t11 drop t0 ;
fib1- dup 2 < if drop 1 exit then dup fib swap 1- fib + ;
bm1cr dup ." bm1: empty loop: (%d)" timer swap for next elapsed ;
bm2cr dup ." bm2: decrement loop: (%d)" timer swap begin 1- -while drop elapsed ;
bm3cr dup ." bm3: call loop: (%d)" timer swap for t0 next elapsed ;
bm4cr dup ." bm4: 2 call loop: (%d)" timer swap for t1 next elapsed ;
bm5cr dup ." bm5: fib (%d) ... " timer swap fib . elapsed ;
bmk1000 mil bm1 ;
go 250 mil dup dup bmk bm2 bm3 bm4 38 bm5 cr ;
go cr
cell var xxx
see xxx cr cr
12345 xxx !
xxx @ ." -xxx created, (%d)-%n"
xxx @ const yyy
yyy ." -yyy created, (%d)-" cr
see yyy cr
t0xxx @ yyy = ." const/var: "if." PASS" exitthen." FAIL!" ; t0