<div dir="ltr">Did you make sure to run it with -mode(compile). ? If you don't the script will be interpreted, and could throw off performance tests.<div><br></div><div>Kelly Wong</div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Tue, Jan 14, 2014 at 3:41 AM, Tim Watson <span dir="ltr"><<a href="mailto:watson.timothy@gmail.com" target="_blank">watson.timothy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I tweaked your module to run via escript (just adding a simple main/1 and printing out the results of timer:tc), and I see a bit gap between foldl and foldr, whilst the hand coded version based on lists:reverse/1 is plenty fast enough:<br>
<br>t4@iske:test $ escript lr.beam 10000000<br>foldl: 679.103ms<br>foldr: 43609.149ms<br>reverse: 909.946ms<br>t4@iske:test $ evm info<br>R16B03 compiled for x86_64-apple-darwin11.4.2, 64bit <br><br>On Friday, 11 May 2012 10:27:29 UTC+1, Ulf Wiger wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>On 11 May 2012, at 04:02, Richard O'Keefe wrote:
<br>
<br>> This can be written more efficiently, but it's best of all
<br>> just not to reverse the string in the first place. Keep
<br>> the code at a level where you can see what's going on well
<br>> enough to spot the really _big_ efficiency gains.
<br>
<br>And this is of course the really important difference between
<br>foldr() and foldl():
<br>
<br>- in which order do you want to process the list?
<br>- if you build a list in the accumulator, in which order do you want it?
<br>
<br>For most practical purposes, one should assume that they
<br>both both do their job efficiently.
<br>
<br>BR,
<br>Ulf
<br>
<br>Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
<br><a href="http://feuerlabs.com" target="_blank">http://feuerlabs.com</a>
<br>
<br>
<br>
<br>______________________________<u></u>_________________
<br>erlang-questions mailing list
<br><a>erlang-q...@erlang.org</a>
<br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a>
<br></blockquote></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>