diff --git a/extra/benchmark/dawes/dawes.factor b/extra/benchmark/dawes/dawes.factor new file mode 100644 index 0000000000..7cff06d1bc --- /dev/null +++ b/extra/benchmark/dawes/dawes.factor @@ -0,0 +1,21 @@ +USING: sequences alien.c-types math hints kernel byte-arrays ; +IN: benchmark.dawes + +! Phil Dawes's performance problem + +: int-length ( byte-array -- n ) length "int" heap-size /i ; inline + +: count-ones ( byte-array -- n ) + 0 swap [ int-length ] keep [ + int-nth 1 = [ 1 + ] when + ] curry each-integer ; + +HINTS: count-ones byte-array ; + +: make-byte-array ( -- byte-array ) + 120000 [ 255 bitand ] map >c-int-array ; + +: dawes-benchmark ( -- ) + make-byte-array 200 swap [ count-ones ] curry replicate drop ; + +MAIN: dawes-benchmark diff --git a/extra/benchmark/typecheck3/typecheck3.factor b/extra/benchmark/typecheck3/typecheck3.factor index b15d81df56..c4887c03c4 100644 --- a/extra/benchmark/typecheck3/typecheck3.factor +++ b/extra/benchmark/typecheck3/typecheck3.factor @@ -3,7 +3,7 @@ IN: benchmark.typecheck3 TUPLE: hello n ; -: hello-n* ( obj -- val ) dup tag 2 eq? [ 3 slot ] [ 3 throw ] if ; +: hello-n* ( obj -- val ) dup tag 2 eq? [ 2 slot ] [ 3 throw ] if ; : foo ( obj -- obj n ) 0 100000000 [ over hello-n* + ] times ;