<br><br><div><span class="gmail_quote">On 6/5/07, <b class="gmail_sendername">Jim Menard</b> <<a href="mailto:jim.menard@gmail.com">jim.menard@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 6/4/07, Ulf Wiger (TN/EAB) <<a href="mailto:ulf.wiger@ericsson.com">ulf.wiger@ericsson.com</a>> wrote:<br>><br>> I ran it on my machine, which scored a miserable<br>> 4.2 seconds. Adding is_float/1 guards around all
<br>> variables that are floats (quite a few) and<br>> compiling with native brought it down to 1.8 secs.<br><br>It sped up my version considerably as well. Why is that? I thought<br>that a guard clause was only used to select which function clause to
<br>run. How does checking to see if something is a float make things<br>faster instead of slowing it down by having to execute is_float/1 for<br>each call?</blockquote><div><br>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 code.
<br></div></div>That's even not "my 2 cents" ;)<br>