heap allocation for MLton object instatiation test?

Doug Bagley doug@bagley.org
Fri, 29 Jun 2001 16:03:24 -0500 (CDT)


Stephen Weeks wrote:
> One can (partially) defeat MLton's current optimizer by replacing the above line
> with the following three.
> 
>       val r = ref (Toggle.new false)
>       val _ = for (0, n - 1, fn _ => r := Toggle.new true)
>       val _ = Toggle.activate (!r)

Sounds good, I'll try that.

> It's really tough to get microbenchmarks in SML (even more so with MLton),
> especially when trying to talk about allocation, since the language
> specification is at a higher level, and gives great freedom for optimizers.

Yes.  I seriously need to overhaul some of my tests to make them more
equitable, in light of the ability of good compilers to optimize away
invariant code.  I'm trying to locate these invariants in my tests
and replace them with something that cascades calculations, which
should prevent that kind of optimization.

Thanks.

Cheers,
Doug