[Shootout-list] ackermann, fibonacci and takfp benchmarks

Daniel South WildCard_25@HotMail.Com
Sat, 19 Mar 2005 22:06:26 +1000


Daniel South wrote:
| Einar Karttunen wrote:
|| "¤WildCard¤" <WildCard_25@HotMail.Com> writes:
|||
||| Easy to add to existing programs. At the start of each function.
||| recursion += 1;
||| depth +=1;
||| if (depth > maxdepth) {maxdepth = depth;}
||
|| This is actually more expensive than recursion in many languages.
|
| Not really

After thinking about it for another minute, I'd have to agree. Most 
compilers will still find this trivial to unroll, thus making 17000 odd 
comparisons for N=6, on the ackermann test, much more expensive than 1 
stack frame allocation. Also this means that the test isn't really 
testing the cost of function calling but rather how well the compiler 
removes function calling :-)

Daniel South