Benchmark updates
parent
5cd014f8ca
commit
f4d2d04093
|
@ -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
|
|
@ -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 ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue