factor/extra/benchmark/dawes/dawes.factor

17 lines
405 B
Factor
Raw Normal View History

USING: alien.c-types sequences kernel math specialized-arrays
fry ;
SPECIALIZED-ARRAY: int
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-12-03 07:21:02 -05:00
: make-int-array ( -- int-array )
2010-01-14 13:08:22 -05:00
120000 iota [ 255 bitand ] int-array{ } map-as ; inline
2008-09-03 08:25:34 -04:00
: dawes-benchmark ( -- )
200 make-int-array '[ _ count-ones ] replicate drop ;
2008-09-03 08:25:34 -04:00
MAIN: dawes-benchmark