Paste: Benchmark

Author: slava
Mode: factor
Date: Tue, 2 Jun 2009 04:28:00
Plain Text |
IN: silly-benchmark
USING: math math.vectors math.functions math.ranges locals kernel sequences formatting ;

:: (iter) ( z c iter max-iter -- count )
    iter max-iter < [
        z absq 4.0 >= [ iter ] [
            z z * c + c iter 1 + >fixnum max-iter (iter)
        ] if
    ] [ max-iter ] if ; inline recursive

: iter ( c max-iter -- count )
    [ dup 0 ] dip (iter) ; inline

CONSTANT: RESOLUTION 5000

:: main ( -- )
    RESOLUTION 2 /i :> max-val
    max-val neg :> min-val
    2.0 max-val /f :> mul
    0
    min-val max-val [a,b] [| i |
        min-val max-val [a,b] [| j |
            i mul *
            j mul * rect>
            100
            iter + >fixnum
        ] each
    ] each
    "result: %d" printf ;

New Annotation

Summary:
Author:
Mode:
Body: