home .. forth .. colorforth mail list archive ..

[colorforth] Ackerman bench mark


Actually, the forth code that behaves more close to the colorForth code
you posted looks like:

 : ack dup if swap dup if 1- over recurse swap 1- recurse exit then
   drop 1 swap 1- recurse exit then  drop 1+ ;
 
and it's a bit of an improvement on bigforth and gforth. It's surprising
how
little changes make noticible differences.

This:

: ACK2 ( n1 n2 -- n3 )  DUP 0= IF drop 1+ EXIT  THEN
  swap dup if 1- OVER RECURSE   SWAP 1- RECURSE exit then
  drop 1 SWAP 1- RECURSE ;

behaves about the same on bigforth but 10% slower in gforth (on a
AMD-K6)

I can't try colorForth unfortunately.

BTW, bigforth is very sensible to first time running benchmarks. Same
benchmark thrown again behaves usally faster; at least on my Linux box.

Joan


Bernd Beuster wrote:
> 
> Somewhere in c.l.f. the Ackerman function was posted.
> 
> \ Ackerman benchmark
> FORTH DEFINITIONS DECIMAL
> 
> : ACK  ( n1 n2 -- n3 )
>   DUP 0= IF  DROP 1+ EXIT  THEN
>   OVER 0= IF  NIP 1 SWAP 1- RECURSE
>   ELSE  SWAP 1- OVER RECURSE   SWAP 1- RECURSE  THEN ;
> 
> : BENCH  999 FOR  6 3 ACK DROP  NEXT ;
> 
> In colorForth it is:
> 
> : ack -1 ? if swap -1 ? if -1 + over ack swap -1 + ack ; then
> drop 1 swap -1 + ack ; then drop 1 + ;
> 
> : bench time - 6 3 ack drop time + ;
> 
> In the c.l.f. posting the parameters were 8 3, but this overuns the
> stacks in bigForth and colorForth.
> 
> Results in clock cycles (Pentium MMX):
> 
> colorForth: 1.65M
> bigForth  : 4.40M
> Gforth    : 19.9M
> 
> So the ratio is 1 : 2.7 : 12.
> 
> --
> Bernd
> ------------------------
> 
> To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
> unsubscribe ColorForth
> as the first and only line within the message body
> Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
> Main ColorForth site   -   http://www.colorforth.com

------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.colorforth.com