No. I suppose &quot;man wc&quot; would have helped, but this has been entertaining, anyway. <br>
Times for lc and wc -l seem comparable over a couple of runs. So in any
case, it's encouraging that it's so easy to reach speeds comparable to
(presumably) highly-tuned C code like this.<br><br>
-Chad<br>
<br><div><span class="gmail_quote">On 6/29/06, <b class="gmail_sendername">Robby Findler</b> &lt;<a href="mailto:robby@cs.uchicago.edu">robby@cs.uchicago.edu</a>&gt; wrote:</span><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
Just out of curiosity, did you try &quot;wc -l&quot;?<br><br>Robby<br><br>On Jun 29, 2006, at 1:18 PM, Chad Scherrer wrote:<br><br>&gt; I have a bunch of data files where each line represents a data<br>&gt; point. It's nice to be able to quickly tell how many data points I
<br>&gt; have. I had been using wc, like this:<br>&gt;<br>&gt; % cat *.txt | /usr/bin/time wc<br>&gt; 2350570 4701140 49149973<br>&gt; 5.81user 0.03system 0:06.08elapsed 95%CPU (0avgtext+0avgdata<br>&gt; 0maxresident)k<br>
&gt; 0inputs+0outputs (152major+18minor)pagefaults 0swaps<br>&gt;<br>&gt; I only really care about the line count and the time it takes. For<br>&gt; larger data sets, I was getting tired of waiting for wc, and I<br>&gt; wondered whether 
ByteString.Lazy could help me do better. So I<br>&gt; wrote a 2-liner:<br>&gt;<br>&gt; import qualified Data.ByteString.Lazy.Char8 as L<br>&gt; main = L.getContents &gt;&gt;= print . L.count '\n'<br>&gt;<br>&gt; ... and compiled this as &quot;lc&quot;. It doesn't get much simpler than
<br>&gt; that. How does it perform?<br>&gt;<br>&gt; % cat *.txt | /usr/bin/time lc<br>&gt; 2350570<br>&gt; 0.09user 0.13system 0:00.24elapsed 89%CPU (0avgtext+0avgdata<br>&gt; 0maxresident)k<br>&gt; 0inputs+0outputs (199major+211minor)pagefaults 0swaps
<br>&gt;<br>&gt; Wow. 64 times as fast for this run, with almost no effort on my<br>&gt; part. Granted, wc is doing more work, but the number of words and<br>&gt; characters aren't interesting to me in this case, anyway. I can't
<br>&gt; imagine (implementation time)*(execution time) being much shorter.<br>&gt; Thanks, Don!<br>&gt;<br>&gt; --<br>&gt;<br>&gt; Chad Scherrer<br>&gt;<br>&gt; &quot;Time flies like an arrow; fruit flies like a banana&quot; -- Groucho Marx
<br>&gt; _______________________________________________<br>&gt; Haskell mailing list<br>&gt; <a href="mailto:Haskell@haskell.org">Haskell@haskell.org</a><br>&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell">
http://www.haskell.org/mailman/listinfo/haskell</a><br><br></blockquote></div><br><br clear="all"><br>-- <br><br>Chad Scherrer<br><br>&quot;Time flies like an arrow; fruit flies like a banana&quot; -- Groucho Marx