2008-12-03 07:21:02 -05:00
|
|
|
USING: sequences hints kernel math specialized-arrays.int fry ;
|
2008-09-03 08:25:34 -04:00
|
|
|
IN: benchmark.dawes
|
|
|
|
|
|
|
|
! Phil Dawes's performance problem
|
|
|
|
|
2008-12-03 07:21:02 -05:00
|
|
|
: count-ones ( int-array -- n ) [ 1 = ] count ; inline
|
2008-09-03 08:25:34 -04:00
|
|
|
|
2008-11-14 21:18:16 -05:00
|
|
|
HINTS: count-ones int-array ;
|
2008-09-03 08:25:34 -04:00
|
|
|
|
2008-12-03 07:21:02 -05:00
|
|
|
: make-int-array ( -- int-array )
|
2008-11-14 21:18:16 -05:00
|
|
|
120000 [ 255 bitand ] int-array{ } map-as ;
|
2008-09-03 08:25:34 -04:00
|
|
|
|
|
|
|
: dawes-benchmark ( -- )
|
2008-12-03 07:21:02 -05:00
|
|
|
make-int-array 200 swap '[ _ count-ones ] replicate drop ;
|
2008-09-03 08:25:34 -04:00
|
|
|
|
|
|
|
MAIN: dawes-benchmark
|