]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/dawes/dawes.factor
5cd40bc0981d1a8b40525c1af40c91052352cc17
[factor.git] / extra / benchmark / dawes / dawes.factor
1 USING: sequences hints kernel math specialized-arrays.int fry ;
2 IN: benchmark.dawes
3
4 ! Phil Dawes's performance problem
5
6 : count-ones ( int-array -- n ) [ 1 = ] count ; inline
7
8 HINTS: count-ones int-array ;
9
10 : make-int-array ( -- int-array )
11     120000 [ 255 bitand ] int-array{ } map-as ;
12
13 : dawes-benchmark ( -- )
14     make-int-array 200 swap '[ _ count-ones ] replicate drop ;
15
16 MAIN: dawes-benchmark