<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>--- On Sat, 11/7/09, Don Stewart &lt;<A href="mailto:dons@galois.com">dons@galois.com</A>&gt; wrote:<BR>&gt; General notes:<BR>&gt;<BR>&gt;&nbsp; * unpack is almost always wrong.<BR>&gt;&nbsp; * list indexing with !! is almost always wrong.<BR>&gt;&nbsp; * words/lines are often wrong for parsing large files (they build large list structures).<BR>&gt;&nbsp; * toList/fromList probably aren't the best strategy<BR>&gt;&nbsp; * sortBy (comparing snd)<BR>&gt;&nbsp; * use insertWith'</DIV>
<DIV>&gt; Spefically, avoid constructing intermediate lists, when you can process the<BR>&gt; entire file in a single pass. Use O(1) bytestring substring operations like<BR>&gt; take and drop.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks all for the valuable feedback. Switching from Regex.Posix to Regex.PCRE alone reduced the running time to about 6 secs and a few other optimizations suggested on this thread brought it down to about 5 secs ;) </DIV>
<DIV>&nbsp;</DIV>
<DIV>I then set out to profile the code out of curiosity to see where the bulk of the time was being spent and sure enough the culprit turned out to be "unpack". My question&nbsp;therefore is, given&nbsp;a&nbsp;list L1&nbsp;of type [(ByteString, Int)], how do I print it out so as to eliminate the "chunk, empty" markers associated with a bytestring? The suggestions posted here are along the lines of "mapM_ print L1" but that's far from desirable especially because the generated output is for perusal by non-technical users etc.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks.<BR></DIV></td></tr></table><br>