benchmark.ant: switching to tuples now that they are fast.
parent
195d5834d4
commit
8579a71efa
extra/benchmark/ant
|
@ -23,19 +23,18 @@ IN: benchmark.ant
|
||||||
: sum-digits ( n -- x )
|
: sum-digits ( n -- x )
|
||||||
0 swap [ dup zero? ] [ 10 /mod swap [ + ] dip ] until drop ;
|
0 swap [ dup zero? ] [ 10 /mod swap [ + ] dip ] until drop ;
|
||||||
|
|
||||||
! FIXME: Find out why this makes it 430 times slower
|
TUPLE: point x y ;
|
||||||
! TUPLE: point x y ;
|
C: <point> point
|
||||||
! C: <point> point
|
|
||||||
|
|
||||||
USE: alien.c-types
|
! USE: alien.c-types
|
||||||
USE: classes.struct
|
! USE: classes.struct
|
||||||
STRUCT: point { x uint } { y uint } ;
|
! STRUCT: point { x uint } { y uint } ;
|
||||||
: <point> ( x y -- point ) point <struct-boa> ; inline
|
! : <point> ( x y -- point ) point <struct-boa> ; inline
|
||||||
|
|
||||||
: walkable? ( point -- ? )
|
: walkable? ( point -- ? )
|
||||||
[ x>> ] [ y>> ] bi [ sum-digits ] bi@ + 25 <= ; inline
|
[ x>> ] [ y>> ] bi [ sum-digits ] bi@ + 25 <= ; inline
|
||||||
|
|
||||||
:: ant ( -- )
|
:: ant-benchmark ( -- )
|
||||||
200000 <hashtable> hash-set boa :> seen
|
200000 <hashtable> hash-set boa :> seen
|
||||||
100000 <vector> :> stack
|
100000 <vector> :> stack
|
||||||
0 :> total!
|
0 :> total!
|
||||||
|
@ -56,4 +55,4 @@ STRUCT: point { x uint } { y uint } ;
|
||||||
] unless
|
] unless
|
||||||
] until total 148848 assert= ;
|
] until total 148848 assert= ;
|
||||||
|
|
||||||
MAIN: ant
|
MAIN: ant-benchmark
|
||||||
|
|
Loading…
Reference in New Issue