diff --git a/extra/benchmark/base64/base64.factor b/extra/benchmark/base64/base64.factor new file mode 100644 index 0000000000..f6e5f7ca39 --- /dev/null +++ b/extra/benchmark/base64/base64.factor @@ -0,0 +1,11 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: math sequences kernel base64 ; +IN: benchmark.base64 + +: base64-benchmark ( -- ) + 65535 [ 255 bitand ] "" map-as + 100 [ >base64 base64> ] times + drop ; + +MAIN: base64-benchmark diff --git a/extra/benchmark/beust2/beust2.factor b/extra/benchmark/beust2/beust2.factor index 833c1fa77d..2ba6ed9775 100644 --- a/extra/benchmark/beust2/beust2.factor +++ b/extra/benchmark/beust2/beust2.factor @@ -5,7 +5,7 @@ IN: benchmark.beust2 ! http://crazybob.org/BeustSequence.java.html -:: (count-numbers) ( remaining first value used max listener -- ? ) +:: (count-numbers) ( remaining first value used max listener: ( -- ) -- ? ) 10 first - [| i | [let* | digit [ i first + ] mask [ digit 2^ ] @@ -26,7 +26,7 @@ IN: benchmark.beust2 ] if ] [ f ] if ] - ] contains? ; inline + ] contains? ; inline recursive :: count-numbers ( max listener -- ) 10 [ 1+ 1 1 0 max listener (count-numbers) ] contains? drop ; diff --git a/extra/benchmark/binary-search/binary-search.factor b/extra/benchmark/binary-search/binary-search.factor new file mode 100644 index 0000000000..1018e643ef --- /dev/null +++ b/extra/benchmark/binary-search/binary-search.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: binary-search math.primes.list math.ranges sequences +prettyprint ; +IN: benchmark.binary-search + +: binary-search-benchmark ( -- ) + 1 1000000 [a,b] [ primes-under-million sorted-member? ] map length . ; + +MAIN: binary-search-benchmark diff --git a/extra/benchmark/empty-loop-0/empty-loop-0.factor b/extra/benchmark/empty-loop-0/empty-loop-0.factor new file mode 100644 index 0000000000..65390e84f2 --- /dev/null +++ b/extra/benchmark/empty-loop-0/empty-loop-0.factor @@ -0,0 +1,10 @@ +USING: math math.private kernel sequences ; +IN: benchmark.empty-loop-0 + +: empty-loop-0 ( n -- ) + dup 0 fixnum< [ drop ] [ 1 fixnum-fast empty-loop-0 ] if ; + +: empty-loop-main ( -- ) + 5000000 empty-loop-0 ; + +MAIN: empty-loop-main diff --git a/extra/benchmark/empty-loop-1/empty-loop-1.factor b/extra/benchmark/empty-loop-1/empty-loop-1.factor new file mode 100644 index 0000000000..36d8722732 --- /dev/null +++ b/extra/benchmark/empty-loop-1/empty-loop-1.factor @@ -0,0 +1,10 @@ +USING: math math.private kernel sequences ; +IN: benchmark.empty-loop-1 + +: empty-loop-1 ( n -- ) + [ drop ] each-integer ; + +: empty-loop-main ( -- ) + 5000000 empty-loop-1 ; + +MAIN: empty-loop-main diff --git a/extra/benchmark/empty-loop-2/empty-loop-2.factor b/extra/benchmark/empty-loop-2/empty-loop-2.factor new file mode 100644 index 0000000000..f7d66b04ab --- /dev/null +++ b/extra/benchmark/empty-loop-2/empty-loop-2.factor @@ -0,0 +1,10 @@ +USING: math math.private kernel sequences ; +IN: benchmark.empty-loop-2 + +: empty-loop-2 ( n -- ) + [ drop ] each ; + +: empty-loop-main ( -- ) + 5000000 empty-loop-2 ; + +MAIN: empty-loop-main diff --git a/extra/benchmark/empty-loop/authors.txt b/extra/benchmark/empty-loop/authors.txt deleted file mode 100755 index 1901f27a24..0000000000 --- a/extra/benchmark/empty-loop/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/extra/benchmark/empty-loop/empty-loop.factor b/extra/benchmark/empty-loop/empty-loop.factor deleted file mode 100644 index 2f9f4f3c94..0000000000 --- a/extra/benchmark/empty-loop/empty-loop.factor +++ /dev/null @@ -1,18 +0,0 @@ -USING: math math.private kernel sequences ; -IN: benchmark.empty-loop - -: empty-loop-0 ( n -- ) - dup 0 fixnum< [ drop ] [ 1 fixnum-fast empty-loop-0 ] if ; - -: empty-loop-1 ( n -- ) - [ drop ] each-integer ; - -: empty-loop-2 ( n -- ) - [ drop ] each ; - -: empty-loop-main ( -- ) - 5000000 empty-loop-0 - 5000000 empty-loop-1 - 5000000 empty-loop-2 ; - -MAIN: empty-loop-main diff --git a/extra/benchmark/mandel/mandel.factor b/extra/benchmark/mandel/mandel.factor index a81e9565a7..2685ff28b7 100755 --- a/extra/benchmark/mandel/mandel.factor +++ b/extra/benchmark/mandel/mandel.factor @@ -26,7 +26,7 @@ IN: benchmark.mandel : iter ( c z nb-iter -- x ) over absq 4.0 >= over zero? or - [ 2nip ] [ 1- >r sq dupd + r> iter ] if ; inline + [ 2nip ] [ 1- >r sq dupd + r> iter ] if ; inline recursive SYMBOL: cols diff --git a/extra/benchmark/nested-empty-loop-1/nested-empty-loop-1.factor b/extra/benchmark/nested-empty-loop-1/nested-empty-loop-1.factor new file mode 100644 index 0000000000..a7dafeebca --- /dev/null +++ b/extra/benchmark/nested-empty-loop-1/nested-empty-loop-1.factor @@ -0,0 +1,29 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: math locals hints ; +IN: benchmark.nested-empty-loop-1 + +:: nested-empty-loop ( n -- ) + n [ + n [ + n [ + n [ + n [ + n [ + n [ + n [ + n [ ] times + ] times + ] times + ] times + ] times + ] times + ] times + ] times + ] times ; + +HINTS: nested-empty-loop fixnum ; + +: nested-empty-loop-main ( -- ) 7 nested-empty-loop ; + +MAIN: nested-empty-loop-main diff --git a/extra/benchmark/nested-empty-loop-2/nested-empty-loop-2.factor b/extra/benchmark/nested-empty-loop-2/nested-empty-loop-2.factor new file mode 100644 index 0000000000..5498067f6f --- /dev/null +++ b/extra/benchmark/nested-empty-loop-2/nested-empty-loop-2.factor @@ -0,0 +1,31 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel math math.ranges sequences locals hints ; +IN: benchmark.nested-empty-loop-2 + +: times ( seq quot -- ) [ drop ] prepose each ; inline + +:: nested-empty-loop ( n -- ) + 1 n [a,b] [ + 1 n [a,b] [ + 1 n [a,b] [ + 1 n [a,b] [ + 1 n [a,b] [ + 1 n [a,b] [ + 1 n [a,b] [ + 1 n [a,b] [ + 1 n [a,b] [ ] times + ] times + ] times + ] times + ] times + ] times + ] times + ] times + ] times ; + +HINTS: nested-empty-loop fixnum ; + +: nested-empty-loop-main ( -- ) 7 nested-empty-loop ; + +MAIN: nested-empty-loop-main diff --git a/extra/benchmark/nsieve-bits/nsieve-bits.factor b/extra/benchmark/nsieve-bits/nsieve-bits.factor index 18dced09cc..4970b018da 100644 --- a/extra/benchmark/nsieve-bits/nsieve-bits.factor +++ b/extra/benchmark/nsieve-bits/nsieve-bits.factor @@ -7,7 +7,7 @@ bit-arrays namespaces io ; 3drop ] [ f 2over set-nth-unsafe >r over + r> clear-flags - ] if ; inline + ] if ; inline recursive : (nsieve-bits) ( count i seq -- count ) 2dup length < [ @@ -17,7 +17,7 @@ bit-arrays namespaces io ; ] when >r 1+ r> (nsieve-bits) ] [ 2drop - ] if ; inline + ] if ; inline recursive : nsieve-bits ( m -- count ) 0 2 rot 1+ dup set-bits (nsieve-bits) ; diff --git a/extra/benchmark/nsieve/nsieve.factor b/extra/benchmark/nsieve/nsieve.factor index 1e327d901a..dd46962322 100644 --- a/extra/benchmark/nsieve/nsieve.factor +++ b/extra/benchmark/nsieve/nsieve.factor @@ -7,7 +7,7 @@ arrays namespaces io ; 3drop ] [ f 2over set-nth-unsafe >r over + r> clear-flags - ] if ; inline + ] if ; inline recursive : (nsieve) ( count i seq -- count ) 2dup length < [ @@ -17,7 +17,7 @@ arrays namespaces io ; ] when >r 1+ r> (nsieve) ] [ 2drop - ] if ; inline + ] if ; inline recursive : nsieve ( m -- count ) 0 2 rot 1+ t (nsieve) ; diff --git a/extra/benchmark/recursive/recursive.factor b/extra/benchmark/recursive/recursive.factor index c8bae8a56a..128ec571f2 100755 --- a/extra/benchmark/recursive/recursive.factor +++ b/extra/benchmark/recursive/recursive.factor @@ -3,14 +3,14 @@ IN: benchmark.recursive : fib ( m -- n ) dup 2 < [ drop 1 ] [ [ 1 - fib ] [ 2 - fib ] bi + ] if ; - inline + inline recursive : ack ( m n -- x ) { { [ over zero? ] [ nip 1+ ] } { [ dup zero? ] [ drop 1- 1 ack ] } [ [ drop 1- ] [ 1- ack ] 2bi ack ] - } cond ; inline + } cond ; inline recursive : tak ( x y z -- t ) 2over <= [ @@ -21,7 +21,7 @@ IN: benchmark.recursive [ 1- -rot tak ] 3tri tak - ] if ; inline + ] if ; inline recursive : recursive ( n -- ) [ 3 swap ack . flush ]