chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] numbers egg slow?


From: Daishi Kato
Subject: Re: [Chicken-users] numbers egg slow?
Date: Thu, 06 Oct 2005 15:47:26 +0900
User-agent: Wanderlust/2.15.1 (Almost Unreal) Emacs/21.4 Mule/5.0 (SAKAKI)

It was too late... Thanks a lot for your examples of measureing.
I will try it a little bit more. --daishi

At Thu, 06 Oct 2005 01:29:08 -0500,
Alex Shinn wrote:
> You have to be careful what you're measuring.  Inside the loop you
> repeatedly call expt, which is slower not only because it makes many
> more checks than before, such as checking the types and signs of the
> arguments, but because it checks the fixnum case last.
> 
> If you bind the result once outside the loop you'll see the time using
> fx+ (and also fx> to be sure we're comparing the same thing) is indeed
> exactly the same:
> 
> $ csi -eval '(let ((2^17 (expt 2 17)))(gc)(time (let loop ([i 0]) (or (fx> i 
> 2^17) (loop (fx+ i 1))))))'
>    0.313 seconds elapsed
>        0 seconds in (major) GC
>       31 mutations
>     1285 minor GCs
>        0 major GCs
> 
> $ csi -R numbers -eval '(let ((2^17 (expt 2 17)))(gc)(time (let loop ([i 0]) 
> (or (fx> i 2^17) (loop (fx+ i 1))))))'
>    0.313 seconds elapsed
>        0 seconds in (major) GC
>       31 mutations
>     1285 minor GCs
>        0 major GCs
> 
> Now let's compare the time of the generic numbers + and normal +:
> 
> $ csi -eval '(let ((2^17 (expt 2 17)))(gc)(time (let loop ([i 0]) (or (> i 
> 2^17) (loop (+ i 1))))))'
>    0.325 seconds elapsed
>        0 seconds in (major) GC
>       31 mutations
>     1289 minor GCs
>        0 major GCs
> 
> $ csi -R numbers -eval '(let ((2^17 (expt 2 17)))(gc)(time (let loop ([i 0]) 
> (or (> i 2^17) (loop (+ i 1))))))'
>    0.454 seconds elapsed
>    0.002 seconds in (major) GC
>       31 mutations
>       58 minor GCs
>        1 major GCs
> 
> 0.454 vs 0.325, or about 1.4x slower when using the full number tower.
> 
> -- 
> Alex




reply via email to

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