chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Good way to code the equivalent to this?


From: Matt Welland
Subject: Re: [Chicken-users] Good way to code the equivalent to this?
Date: Sun, 24 Aug 2008 22:20:25 -0700

Wow, thanks. That cut my run time in half to aprox 8..4 seconds. I'm
using chicken 2.74 on this machine. I've tried 3.3 at a different
machine but not seen much difference.

Note that changing to non-hierarchical hashes breaks a lot of my
existing code and is not exactly apples to apples with the perl. Still
useful though and I may be able to use that approach with a little
foresight next time.

On Sun, Aug 24, 2008 at 9:36 PM, Alex Shinn <address@hidden> wrote:
>>>>>> "Matt" == Matt Welland <address@hidden> writes:
>
>    Matt> chicken: ~16 secs (when it didn't crash)
>    Matt> stk: ~17 secs
>    Matt> ruby: ~1.3 secs
>    Matt> perl: ~0.7 secs
>
> Which Chicken version are you timing, and with what compiler
> optimizations?  If you use -Ob and a suitable initial heap
> size, then on my machine elf's version runs in under 700ms,
> as opposed to ~500ms for the Perl version.  Use the command:
>
>  $ csc -Ob -heap-initial-size 300M file.scm
>
> If you really just want to get the job done regardless of
> method, you can note that in this particular case a simple
> vector is suitable and skip the hash tables altogether.
>
> This is over twice as fast as the perl version:
>
> ------------------------------------------------------------------------
> (define a (make-vector 500000 '()))
>
> (print "filling ...")
>
> (do ((i 0 (add1 i)))
>    ((>= i 250000))
>  (let ((x (random 500000))
>        (y (random 500000)))
>    (vector-set! a x (cons y (vector-ref a x)))))
>
> (print "reading ...")
>
> (define hits 0)
>
> (do ((i 0 (add1 i)))
>    ((>= i 10000))
>  (let ((x (random 500000))
>        (y (random 500000)))
>    (if (memq y (vector-ref a x))
>        (set! hits (add1 hits)))))
>
> (print "done.")
> ------------------------------------------------------------------------
>
>
> --
> Alex
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]