On Sun, Dec 28, 2008 at 1:38 AM, Thomas DuBuisson <span dir="ltr">&lt;<a href="mailto:thomas.dubuisson@gmail.com">thomas.dubuisson@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&nbsp; &nbsp; &nbsp; getNthWord n bs@(PS ptr off len) =<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inlinePerformIO $ withForeignPtr ptr $ \ptr&#39; -&gt; do<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let p = castPtr $ plusPtr ptr&#39; off<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; peekElemOff p n<br>
<br>
But even this low level code seems to be excessively slow with 33% of<br>
the MD5 run time attributed to this function. &nbsp;I ment to investigate<br>
this a couple months ago but have had zero time.<br>
</blockquote><div><br>The overhead here is very probably caused by withForeignPtr. In similar cases, I&#39;ve seen much better performance from hoisting this to the outside of a loop. <br></div></div>