[erlang-questions] Blog: Erlang Fractal Benchmark

Ludovic Coquelle lcoquelle@REDACTED
Tue Jun 5 09:50:11 CEST 2007

On 6/5/07, Jim Menard <jim.menard@REDACTED> wrote:
> On 6/4/07, Ulf Wiger (TN/EAB) <ulf.wiger@REDACTED> wrote:
> >
> > I ran it on my machine, which scored a miserable
> > 4.2 seconds. Adding is_float/1 guards around all
> > variables that are floats (quite a few) and
> > compiling with native brought it down to 1.8 secs.
> It sped up my version considerably as well. Why is that? I thought
> that a guard clause was only used to select which function clause to
> run. How does checking to see if something is a float make things
> faster instead of slowing it down by having to execute is_float/1 for
> each call?

I have never look at the compiler code, but I think than doing the test
"is_float" is quite easy, and after that the compiler can assume that the
argument is float and thus it can use the dedicated instruction of the
machine ... I'm not so clear about what really happens but I imagine than
more the compiler has constraints more it can optimize the production of
That's even not "my 2 cents" ;)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070605/3a90ca42/attachment.htm>

More information about the erlang-questions mailing list