Hi Alex,

thanks for explanation.

I was curious to try picolisp bignums and must say that for somebody
doing anything serious, it is probably rather inefficient.  As a
benchmark, I tried the example from
http://paste.lisp.org/display/15116

(setq X 0)
(setq Y 1)
(for (N 2 (<= N 1000000) (inc N))
   (let Z (+ X Y)
      (setq X Y)
      (setq Y Z)))
(prinl Y)

Very rough results using picolisp native bignums:

(<= N 10000)

$ time ~/picolisp/p gmp-test2.l -bye > gmp-test2.log

real    0m0.131s
user    0m0.124s
sys         0m0.008s

(<= N 100000)

$ time ~/picolisp/p gmp-test2.l -bye > gmp-test2.log

real    0m10.190s
user    0m10.157s
sys         0m0.008s

(<= N 1000000)

$ time ~/picolisp/p gmp-test2.l -bye > gmp-test2.log
  C-c C-cKilled

real    17m58.856s
user    17m51.687s
sys         0m5.572s

(killed after 18 mins!)

The original C program:

$ time ./gmp > gmp.log

real    0m50.060s
user    0m50.059s
sys         0m0.004s

I wrote simple ffi wrapper for gmp library and the results:

$ time ../../p gmp-test.l -bye > gmp-test.log

real    0m50.507s
user    0m50.239s
sys         0m0.248s

using the following code:

(setq X (mpz_new))
(setq Y (mpz_new))
(mpz_init X)
(mpz_init Y)
(mpz_set_ui X 0)
(mpz_set_ui Y 1)
(setq Z (mpz_new))
(for (N 2 (<= N 1000000) (inc N))
   (mpz_init Z)
   (mpz_add Z X Y)
   (mpz_set X Y)
   (mpz_set Y Z)
   (mpz_clear Z))
(mpz_print Y)
(prinl)

Would not it be better to use gmp library for bignums if they are
going to be supported?

What is the reason picolisp has bignums in the first place?  Do
you/somebody else use it for anything?  Would not it be simpler and
good enough on 64 bit systems not having them at all?

What impact on interfacing foreign libraries the asm rewrite have?

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to