[Top][All Lists]
[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
>
- Re: [Chicken-users] Good way to code the equivalent to this?, (continued)
Re: [Chicken-users] Good way to code the equivalent to this?, Elf, 2008/08/24
Re: [Chicken-users] Good way to code the equivalent to this?, Elf, 2008/08/24
Re: [Chicken-users] Good way to code the equivalent to this?, Jim Ursetto, 2008/08/24
Re: [Chicken-users] Good way to code the equivalent to this?, Matt Welland, 2008/08/24
- Message not available
- Re: [Chicken-users] Good way to code the equivalent to this?,
Matt Welland <=
Re: [Chicken-users] Good way to code the equivalent to this?, Tobia Conforto, 2008/08/25