[plt-scheme] List loop timing

From: Andrew Reilly (andrew-scheme at areilly.bpc-users.org)
Date: Thu Feb 14 03:58:52 EST 2008

Thanks for doing these benchmarks!  I was wondering exactly the
same thing, the last couple of days.

I expected the result to come out the way you describe it, on
the strenght that the foldr-style loop does it's intermediate
allocation on the stack, and creates the result list on the heap
only once.  So it's probably doing a bit *more* allocation than
the tail-call+reverse version (because it's also allocating
return addresses), but half of that is "collected" eagerly and
precicely, as the nest of calls unravels.  So there's half as
much garbage to collect, and the stack space is more likely to
be re-used in the cache.

Well, that's my theory, anyway.



Posted on the users mailing list.