2008-11-14 21:18:16 -05:00
|
|
|
USING: sequences hints kernel math specialized-arrays.int ;
|
2008-09-03 08:25:34 -04:00
|
|
|
IN: benchmark.dawes
|
|
|
|
|
|
|
|
! Phil Dawes's performance problem
|
|
|
|
|
2008-11-14 21:18:16 -05:00
|
|
|
: count-ones ( byte-array -- n ) [ 1 = ] sigma ;
|
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
|
|
|
|
|
|
|
: make-byte-array ( -- byte-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 ( -- )
|
|
|
|
make-byte-array 200 swap [ count-ones ] curry replicate drop ;
|
|
|
|
|
|
|
|
MAIN: dawes-benchmark
|