<div dir="ltr">Switching to quotRem gave no measurable improvements.<div>After switching to ByteString, the code now runs in 9 seconds, which outperforms my C version. But honestly, I have no idea why.</div><div><br></div>

<div>New code:</div><div><a href="http://lpaste.net/100136">http://lpaste.net/100136</a><br></div><div><br></div><div><div>$ ghc --make -O3 303only012.hs && time ./303only012 50000000 > /dev/null</div><div>./303only012 50000000 > /dev/null  9.72s user 0.21s system 90% cpu 10.961 total</div>

</div><div><br></div><div>@Alois, I'm not sure how criterion can help compare my code with the C version, since in the C version I cannot measure the exec time of only012 only. What did you have in mind?</div><div><br>

</div><div>Thanks everyone!</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div>--  <br>Cp</div>
<br><br><div class="gmail_quote">On Wed, Feb 19, 2014 at 7:24 PM, Levent Erkok <span dir="ltr"><<a href="mailto:erkokl@gmail.com" target="_blank">erkokl@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">Also, prefer quotRem over divMod as the former is faster. See here: <a href="http://stackoverflow.com/questions/339719/when-is-the-difference-between-quotrem-and-divmod-useful" target="_blank">http://stackoverflow.com/questions/339719/when-is-the-difference-between-quotrem-and-divmod-useful</a></div>


<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 19, 2014 at 10:19 AM, Gregory Collins <span dir="ltr"><<a href="mailto:greg@gregorycollins.net" target="_blank">greg@gregorycollins.net</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"><div class="gmail_extra"><div class=""><div><br><div class="gmail_quote">On Wed, Feb 19, 2014 at 9:36 AM, Charles-Pierre Astolfi <span dir="ltr"><<a href="mailto:cpa@crans.org" target="_blank">cpa@crans.org</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So there's a difference, but I'm not sure if it's related to my algorithm or related to IO/RTS.</blockquote>



</div><br></div></div>Text.Printf is slower than the C version (and uses String). Use Data.ByteString.putStr instead.<span><font color="#888888"><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>

-- <br>Gregory Collins <<a href="mailto:greg@gregorycollins.net" target="_blank">greg@gregorycollins.net</a>>
</font></span></font></span></div></div><div class="">
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></div></blockquote></div><br></div>
</blockquote></div><br></div>