I wrote:
> 
> Serge D. Mechveliani wrote:
> > 
> > People,
> > 
> > can you, please, answer the following beginner questions on compilation 
> > and performance
> > (for  FriCAS-1.1.5 - GNU CLISP 2.48 - Debian Linux). 
> 
> I tried 5 versions of your code on different Lisp versions:
> 
>                         Clisp     ecl        sbcl
> ct1(4*10^5)             0.66      0.18       0.08
> ct2(4*10^5)             0.72      0.18       0.07
> ct3(4*10^5)             5.59      1.08       2.04
> ct4(4*10^5)             0.64      0.13       0.05
> ct5(4*10^5, all)        0.64      0.14       0.05
> 

I added another one using '#' for string length:

                clisp       ecl    sbcl
ct6(4*10^5)      0.06      0.02    0.01
ct6(4*10^7)      5.96      1.28    0.49

As you can see this one is about 10 time faster (no wonder,
length is stored together with characters and '#' only has
to read it from meomory).  For sbcl '#' takes only 12% of
execution time (the rest is arithmetic on 'i' and
loop overhead).

BTW: All your version use bignums for arithmetic and loop
control.  You can make it faster restricting arguments
to SingleInteger.  In interpreter this gives little gain
(of order 30%), but the following Spad version (a little
variation of Ralf code) is much faster:

)abbrev package COUNT Count
Count(): with
     ct: SingleInteger -> SingleInteger
   == add
     ct(n: SingleInteger) : SingleInteger ==
         str: String := "abc"
         i := n
         while 0 < i repeat
             i := i - (#str pretend SingleInteger)
         return i

with sbcl ct(4*10^7) is 0.02 sec while ct(4*10^8) take 0.14 sec.
So another factor of 30.

-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to