[Top][All Lists]

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

Re: [Chicken-users] big prime number

From: Peter Bex
Subject: Re: [Chicken-users] big prime number
Date: Sun, 24 Jan 2016 23:18:49 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Jan 24, 2016 at 03:25:04PM -0500, Claude Marinier wrote:
> Bonjour,

Hello Claude,

> Here is the program (minus timing code).
> (use numbers)
> (define big-prime (- (expt 2 74207281) 1))
> (define big-print-str (number->string big-prime))
> (define outport (open-output-file "big-prime.txt"))
> (display big-prime outport) (newline outport)
> (close-output-port outport)
> A colleague claims a Haskell program calculating the prime and writing it
> to a file ran in 17 seconds. That's 89 times faster.
> Am I missing something? Is 4.10.1 faster?

Ouch, that's pretty bad indeed.  I ran the program on my Lenovo X230,
and it took 619 seconds, which is consistent with your findings.  I took
a look at the profile (yay for the new profiler!) and it looks like it's
spending a WHOLE lot of time in Karatsuba multiplication, which is
probably due to the "integer-power" call in integer->string.  I'll have
to look into this deeper, to see whether this can be improved at all.

Now, the good news is that I also ran the program under CHICKEN 5 and
it took just under 17 seconds to complete.  Most likely this is because
the whole thing can be done completely inline, without any CPS calls,
which means a lot less allocation, which in turn means a lot less
garbage collections need to be performed.  So again many thanks to Felix
for pushing me to make all operators have inlineable C functions!


Attachment: signature.asc
Description: Digital signature

reply via email to

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