[Shootout-list] ackermann, fibonacci and takfp benchmarks
Einar Karttunen
ekarttun@cs.helsinki.fi
Sat, 19 Mar 2005 13:33:49 +0200
"Daniel South" <WildCard_25@HotMail.Com> writes:
> Not really, generally, allocating a new stack frame is more expensive
> than a comparison. The difference will be that global scope variables
> will be changed on every call and *then* compared to, making it harder
> to for the compiler to optimise out the recursion ie. it rely has to
> recurse and not just use a cached value. This will of course impact the
> languages that had been optimising out the recursions, but the whole
> point is to test the cost of calling the function, not to test how well
> the compiler optimises. Tail recursion optimisation should not be
> affected, just the caching.
The problem is that not all languages have cheap mutable variables.
> As a side note: in what languages would a register comparison be more
> expensive than stack frame allocation?
foo += 1
will become modifyIORef foo (\v -> v `seq` v+1) in Haskell.
This calls an external function (in C--) of ~40 lines,
which applies the anonymous function to update the current
value of the ioref.
- Einar Karttunen