# Re: [stack] Digest Number 89

## Soren Renner — 2000-09-10 16:21:45

    [ 1 [1 plus] 10000000 times] ... this takes about 4 seconds on my 400 mhz x86 box running NO System 3 -- about 2.5 million additions per second. How does this compare with the Joy-in-C machines?

     >

    >

    > Using official Joy, compiled with gcc -O2, I get 7.5 seconds on a 466Mhz

    > celeron and 6.4 seconds on a 333Mhz ppc (iMac).

    >

     Interesting. Post a benchmarking suite. When there is blood in the water it is time to fish or cut bait.

    sr

## stevan apter — 2000-09-10 18:11:44

    try http://inferno.bell-labs.com/cm/cs/who/bwk/interps/pap.html

    k results can be found at http://www.kx.com/a/k/examples/bell.k

    since conk is k with concatenative syntax, the timings carry over.

    btw, trading off time for space, on my pentium II 450 mhz

        1 10000000 take 1 [+] over

    440 ms

    more than half of which is used to construct the list of 10m ints.  so

    the pure arithmetic takes about 200 ms.

    for some problems, the native vector capabilities of conk will give

    performance advantages.  e.g. draw two sets of 10 million random

    floats between 0 and 1 (without replacement) and add them together

        0 10000000 draw 0 10000000 draw +

    630 ms

    this kind of thing starts to make a real difference when the data

    are large and the computations are naturally array-oriented.

     ----- Original Message -----

    From: "Soren Renner" <srenner@...>

    To: <concatenative@egroups.com>

    Sent: Sunday, September 10, 2000 12:21 PM

    Subject: Re: [stack] Digest Number 89

    >

    >

    >  [ 1 [1 plus] 10000000 times] ... this takes about 4 seconds on my 400 mhz x86 box running NO System 3 -- about 2.5 million

    additions per second. How does this compare with the Joy-in-C machines?

    > >

    >

    > >

    > > Using official Joy, compiled with gcc -O2, I get 7.5 seconds on a 466Mhz

    > > celeron and 6.4 seconds on a 333Mhz ppc (iMac).

    > >

    >

    > Interesting. Post a benchmarking suite. When there is blood in the water it is time to fish or cut bait.

    >

    > sr

    >

    > To unsubscribe from this group, send an email to:

    > concatenative-unsubscribe@egroups.com

    >

    >

    >

    >

## Louis Madon — 2000-09-11 08:55:44

    stevan apter wrote:

    ...

     > btw, trading off time for space, on my pentium II 450 mhz

    >

    >     1 10000000 take 1 [+] over

    > 440 ms

    >

    > more than half of which is used to construct the list of 10m ints.  so

    > the pure arithmetic takes about 200 ms.

    >

    > for some problems, the native vector capabilities of conk will give

    > performance advantages.  e.g. draw two sets of 10 million random

    > floats between 0 and 1 (without replacement) and add them together

    >

    >     0 10000000 draw 0 10000000 draw +

    > 630 ms

    >

    > this kind of thing starts to make a real difference when the data

    > are large and the computations are naturally array-oriented.

     Those are pretty good times.  Did you do a test against the original

    example too?

    I thought it would be interesting to do a comparison against other

    languages (based on the example Soren posted). The only difference is

    that instead of applying a quotation 10m times, I applied a lambda 10m

    times.  I tried Haskell, O'Caml and C and got these results (with Joy

    shown for reference):

                      time (in seconds, on a celeron 466)

    Joy                  7.5

    Haskell (hugs)     283

    Haskell (ghc)        4.9

    O'Caml               0.37

    C       (gcc)        0.24

    The most suprising result for me, was the poor showing of ghc (a Haskell

    compiler) - it was almost as slow as the Joy interpreter; nearly 14

    times slower than the O'Caml version and 20 times slower than the C

    version.

    For completeness, here is the way I coded each version:

    Haskell

    -------

      module Main(main) where

      test = times 10000000 (\x -> x + 1) 1

      times n f x =

        if n > 0 then (times (n - 1) f) $! (f x) else x

      main = putStrLn (show test)

    O'Caml

    ------

      let rec times n f x =

        if n > 0 then times (n - 1) f (f x) else x ;;

      let test = times 10000000 (function x -> x + 1) 1 ;;

      let main () =

        print_int(test);

        print_newline();

        exit 0;;

      main ();;

    C version

    ---------

      #include <stdio.h>

      int times (int n, int (*f)(int), int x)

      {

          for (int i = 0; i < n; ++i)

          {

            x = f(x);

          }

          return x;

      }

      // the x = x + 1 "lambda"

      int inc(int x)

      {

        return (x + 1);

      }

      int main()

      {

        int test = times(10000000, inc, 1);

        printf("%d\n", test);

        return 0;

      }

    --

    Louis.

## Stefano Lanzavecchia — 2000-09-11 10:50:26

    --- In concatenative@egroups.com, Louis Madon <madonl@b...> wrote:

     > The most suprising result for me, was the poor showing of ghc (a

     Haskell

     > compiler) - it was almost as slow as the Joy interpreter; nearly 14

    > times slower than the O'Caml version and 20 times slower than the C

    > version.

     May this not be caused by the fact that by default Haskell uses

    extended (i.e.: infinite) precision integers?

    --

        WildHeart'2k

## stevan apter — 2000-09-11 11:40:49

    ----- Original Message -----

    From: "Louis Madon" <madonl@...>

    To: <concatenative@egroups.com>

    Sent: Monday, September 11, 2000 4:55 AM

    Subject: Re: [stack] Digest Number 89

    >

    > stevan apter wrote:

    > ...

    > > btw, trading off time for space, on my pentium II 450 mhz

    > >

    > >     1 10000000 take 1 [+] over

    > > 440 ms

    > >

    > > more than half of which is used to construct the list of 10m ints.  so

    > > the pure arithmetic takes about 200 ms.

    > >

    > > for some problems, the native vector capabilities of conk will give

    > > performance advantages.  e.g. draw two sets of 10 million random

    > > floats between 0 and 1 (without replacement) and add them together

    > >

    > >     0 10000000 draw 0 10000000 draw +

    > > 630 ms

    > >

    > > this kind of thing starts to make a real difference when the data

    > > are large and the computations are naturally array-oriented.

    >

    > Those are pretty good times.  Did you do a test against the original

    > example too?

    yes.  nothing special there.  scalar iteration isn't k's (or conk's)

    strong point:

        \t 10000000 (1+)/1

    4957 ms

        1 [1+] 10000000 times

    6432 ms