]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/dawes/dawes.factor
core: Rename iota to <iota> so we can have TUPLE: iota ... ; instead of TUPLE: iota...
[factor.git] / extra / benchmark / dawes / dawes.factor
1 USING: alien.c-types sequences kernel math specialized-arrays
2 fry ;
3 SPECIALIZED-ARRAY: int
4 IN: benchmark.dawes
5
6 ! Phil Dawes's performance problem
7
8 : count-ones ( int-array -- n ) [ 1 = ] count ; inline
9
10 : make-int-array ( -- int-array )
11     120000 <iota> [ 255 bitand ] int-array{ } map-as ; inline
12
13 : dawes-benchmark ( -- )
14     200 make-int-array '[ _ count-ones ] replicate drop ;
15
16 MAIN: dawes-benchmark