0 [if] for j in \ bench-x-comp \ bench-x-exec \ bench-z1-comp \ bench-z1-exec \ bench-z2-comp \ bench-z2-exec \ bench-w-comp \ bench-w-exec \ "' z1 is w bench-w-nois-comp" \ "' z1 is w ' w bench-w-nois-exec" do echo $j for i in \ ~/"nfstmp/gforth-amd64/gforth-fast -e" \ iforth \ lxf \ sf64 \ sf64-4.0.0-RC87 \ vfx64 do taskset -c 2 perf stat --log-fd 3 -x, -e cycles:u -e instructions:u -e L1-icache-load-misses:u -e L1-dcache-load-misses:u -e branch-misses:u $i "include `pwd`/bench.fs $j bye" 3>&1 >/dev/null 2>/dev/null | awk -F, '{x[$3]=$1} END {s=100000000; printf("%5.1f & %4.1f & %1.1f & %1.1f & %1.1f & ",x["cycles:u"]/s,x["instructions:u"]/s,x["L1-icache-load-misses"]/s,x["L1-dcache-load-misses"]/s,x["branch-misses:u"]/s)}' echo $i '\\' done done [then] create x 0 , : d1 ( "name" -- ) create 0 , does> ( -- addr ) ; : d2 ( "name" -- ) create 0e f, does> ( -- ) 1e dup f@ f+ f! ; d1 z1 d2 z2 0 constant my0 defer w ' my0 is w 100000000 constant iterations : bench-x-comp ( -- ) iterations 0 ?do 1 x +! loop ; : bench-z1-comp ( -- ) iterations 0 ?do 1 z1 +! loop ; : bench-z2-comp ( -- ) iterations 0 ?do z2 loop ; : bench-w-comp ( -- ) ['] my0 ['] drop iterations 0 ?do w over [defined] [is] [if] [is] w [else] is w [then] loop 2drop ; : bench-x-exec ( -- ) ['] x iterations 0 ?do 1 over execute +! loop drop ; : bench-z1-exec ( -- ) ['] z1 iterations 0 ?do 1 over execute +! loop drop ; : bench-z2-exec ( -- ) ['] z2 iterations 0 ?do dup execute loop ; : bench-w-exec ( -- ) ['] w dup ['] my0 ['] drop iterations 0 ?do 3 pick execute over [defined] [is] [if] [is] w [else] is w [then] loop 2drop drop ; \ usage: ' z1 is w bench-w-nois-comp : bench-w-nois-comp ( -- ) iterations 0 ?do w drop loop ; \ usage: ' z1 is w ' w bench-w-nois-exec : bench-w-nois-exec ( xt -- ) iterations 0 ?do dup execute drop loop drop ;