File tree 5 files changed +234
-117
lines changed
5 files changed +234
-117
lines changed Original file line number Diff line number Diff line change
1
+ \ measure the two words given in the manual
2
+
3
+ \ invoke with gforth-fast -e "1 7" bench/stagediv.fs
4
+ \ where 1 (or 2) is the number of stages, and 7 is the u for array/
5
+
6
+ \ for j in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 100 2000; do echo $j; for i in 1 2; do perf stat -e cycles:u gforth-fast -e "$i $j" bench/stagediv.fs |& grep cycles:u; done; done
7
+
8
+
9
+ constant u
10
+ constant stages
11
+
12
+
13
+ stages 1 = [if]
14
+ : array/ ( addr u n -- )
15
+ -rot cells bounds u+do
16
+ i @ over / i !
17
+ 1 cells +loop
18
+ drop ;
19
+ [then]
20
+ stages 2 = [if]
21
+ : array/ ( addr u n -- )
22
+ {: | reci[ staged/-size ] :}
23
+ reci[ /f-stage1m
24
+ cells bounds u+do
25
+ i @ reci[ /f-stage2m i !
26
+ 1 cells +loop ;
27
+ [then]
28
+
29
+ #2000 constant #elems
30
+ create orig #elems cells allot
31
+ create working #elems cells allot
32
+
33
+ : init ( -- )
34
+ 1000000 #elems 0 do
35
+ dup orig i th ! 10 +
36
+ loop ;
37
+
38
+ init
39
+
40
+ : bench ( -- )
41
+ 10000000 #elems / 0 ?do
42
+ orig working #elems cells move
43
+ working #elems u / 0 ?do
44
+ dup u 3 array/
45
+ u cells +
46
+ loop
47
+ drop
48
+ loop ;
49
+ bench
50
+ bye
51
+
52
+
You can’t perform that action at this time.
0 commit comments