Re: [Chicken-users] big prime number

2016-01-24 Thread Dan Leslie

Peter Bex  writes:

> 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!

I am very much looking forward to Chicken 5.

:D

-Dan


signature.asc
Description: PGP signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Scraping the REPL?

2016-01-24 Thread Hefferon, James S.
Thank you, Dan for the warning.

Matt, about script: that sounds like it might be perfect for me.  I do use 
Linux, as it is good for LaTeX.  Sorry for my confusion; I'll check it out.

Regards,
Jim

--
"Does not the Captain seek your advice, sir?"
"Not always," said Stephen.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Scraping the REPL?

2016-01-24 Thread Dan Leslie

Word of warning: Babel seems to be hard-coded for Guile only; there are
several open bugs regarding Babel and Geiser regarding, for instance, it
breaking with Chicken.

-Dan

Alex Charlton  writes:

> Hi James,
>
> The best thing that I've found for creating "living" documents is Org-mode's
> Babel . It allows you to write
> code in a document which is  executed when the document is compiled, with
> the source and/or the results getting inserted into the document (which can
> be transformed to LaTeX). If your code generates images, you can even have
> them inserted, too (likely not what you're looking for, but still a cool
> feature!) However, there is one big caveat: Org-mode is an Emacs mode, so
> not only would you need to use Emacs, but so would anyone compiling the
> document. I could understand if this is too much of a barrier of entry for
> your liking.
>
> Another suggestion which seems a bit more in line with your desires would
> be to use a macro like so:
>
> (define counter (make-parameter 1))
>
> (define-syntax repl-print
>   (syntax-rules ()
> ((_ form)
>  (let ((result form))
>(printf "#;~s> ~s~%" (counter) (quote form))
>(unless (equal? result (void))
>  (print result))
>(counter (add1 (counter)))
>
> Which can then be used like so:
> (repl-print (+ 5 1))
> (repl-print (define (f x)  (+ x 1)))
> (repl-print (f 5))
>
> with e.g. something like  `csi -script foo.scm > foo.out` to produce almost
> the same output as your example. One issue this macro has is that it
> doesn't know about whitespace, so you're kind of limited to one line. You
> could work around that by using a pretty printer with a bit of padding
> magic, but it still won't give you "proper" Scheme indentation. Still, most
> REPL examples should be one-liners, I'd think (and hope for your sake ;) )
>
> Whatever you choose to do, good luck with your project! I look forward to
> seeing the result :)
>
> Alex
>
> On Sat, Jan 23, 2016 at 12:51 PM Hefferon, James S. 
> wrote:
>
>>
>> Thank you for the "script" suggestion.  I apologize but I don't understand
>> it.
>>
>> I'm looking for a way to automatically capture an interactive session, and
>> drop
>> it to a file, without cutting and pasting from a terminal or an editor.
>>  When I use
>> LaTeX to compile the book, I'd like that as part of the compilation it runs
>> Chicken's csi and captures the session, so that session can be
>> brought into the document.  (My past experience with cutting and pasting
>> is that as
>> the document changes the code samples get out of sync.  In addition, I'd
>> like that
>> if a person gets the doc off my github account and they compile the doc
>> then they
>> know their setup matches their doc.)
>>
>> That is, I'd like to feed this to csi, and then grab the transcript.
>>
>> #;1> (+ 5 1)
>> 6
>> #;2> (define (f x)
>> (+ x 1))
>> #;3> (f 5)
>> 6
>>
>> I can get LaTeX to run programs, for example to call "csi -script foo.scm
>> > foo.out".  But
>> I'm not sure if it is possible to grab the REPL without an Expect-type
>> situation.
>>
>> I understand "script" it will give me a single output, and not show the
>> REPL at all.
>> Am I missing the point (probably)?
>>
>> Thank you,
>> Jim
>> ___
>> Chicken-users mailing list
>> Chicken-users@nongnu.org
>> https://lists.nongnu.org/mailman/listinfo/chicken-users
>>
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users



signature.asc
Description: PGP signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] big prime number

2016-01-24 Thread Peter Bex
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!

Cheers,
Peter


signature.asc
Description: Digital signature
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] big prime number

2016-01-24 Thread Claude Marinier
Bonjour,

Spurred by the recent excitement about a new largest prime number (1), I
wanted to see how long it would take to just write the number. So I wrote a
simple program and added timing to produce the following.

claude@hibou:~/Programming/scheme$ ./big-prime
time to compute big prime : 1.074 seconds
time to convert it to a string : 778.617 seconds
time to write it to a file : 710.805 seconds

I compiled the program on Debian 8 64-bit with Chicken 8.10.0 and Numbers
4.3 and "-O3". The CPU is an old dual-core Pentium E2200 @ 2.20GHz.

Version 4.10.0 (rev b259631)
linux-unix-clang-x86-64 [ 64bit manyargs dload ptables ]
compiled 2015-08-04 on yves.more-magic.net (Linux)

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?

Back in June, there was talk of Numbers performance. Where do we stand now?
Should I try the code in GIT?

Thank you.

P.S. He may have written the number in binary. That would explain a lot.
Still, am I missing something? Hum ... I should probably use cpu-time
instead of current-milliseconds but (oddly) I do not know have to deal with
the two returned values. :-(

(1) http://www.mersenne.org/primes/?press=M74207281

-- 
Claude Marinier
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users