<br><br><div class="gmail_quote">On Fri, Oct 15, 2010 at 8:23 PM, Ronny Pfannschmidt <span dir="ltr">&lt;<a href="mailto:Ronny.Pfannschmidt@gmx.de">Ronny.Pfannschmidt@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Sun, 2010-02-28 at 16:38 -0500, Alfredo Deza wrote:<br>
&gt; After Ned Batchelder&#39;s talk in Python I spent a few minutes talking<br>
&gt; about how nice it is to have as much (or even more!) test code lines<br>
&gt; than source code lines.<br>
&gt;<br>
&gt; I have put together a small script that will count the lines of code<br>
&gt; in a given directory and will compare them to your test code lines<br>
&gt; with a nice output (e.g. percentage, total lines, lines per file<br>
&gt; etc...).<br>
&gt;<br>
&gt; Ideally, this could become a plugin for Nose (or py.test), but for<br>
&gt; now, it will create an executable symlink so you can run it anywhere.<br>
&gt;<br>
&gt; The project page: <a href="http://code.google.com/p/pygora/" target="_blank">http://code.google.com/p/pygora/</a><br>
&gt;<br>
&gt; I am using distribute to package Pygora, you can install it by:<br>
&gt;<br>
&gt;         sudo easy_install pygora<br>
&gt;<br>
&gt; And, if you were not wondering already, the name comes from a *goat*:<br>
&gt; Pygora Goat is a cross between the Pygmy Goat and the Angora Goat that<br>
&gt; produces three distinct kinds of fleece and has the smaller size of<br>
&gt; the Pygmy.<br>
&gt; Source: Wikipedia<br>
&gt;<br>
&gt;<br>
&gt; Pygora could do better in telling what lines to count with a nice<br>
&gt; regex, but this first release will get you an idea, enhancements will<br>
&gt; follow.<br>
<br>
</div></div>you might want to take a look at py.countloc which is shipped by py (and<br>
will be in pycmd in future) </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
py.countloc provides way better numbers (imho)<br>
<div class="im"><br></div></blockquote><div><br></div><div>Since I had py.test installed I tried out py.countloc, and I have a few comments...</div><div><br></div><div>The idea behind pygora is to have a comparison ratio, to know where your test line numbers</div>
<div>are related to those of your source code, this is not provided by py.countloc</div><div><br></div><div>In the latest pygora version (you have actually replied to the first announcement dated in February) </div><div>speed was improved a lot, and in fact after benchmarking both tools pygora takes almost </div>
<div>half the time to go through a path and get the metrics.</div><div><br></div><div>For example, in a directory with around 1,5 million lines of code these are the times I got (best out of 3 runs):</div><div><br></div><div>
py.countloc  4.04s user 0.50s system 99% cpu 4.572 total</div><div><br></div><div>pygora  2.52s user 0.66s system 97% cpu 3.253 total</div><div><br></div><div>There is also no way to tell py.countloc to avoid printing *every* single file it is counting. This is specially </div>
<div>annoying for 1.5m lines of code, also, no way of filtering or excluding certain files.</div><div><br></div><div>All of those options are available with pygora (e.g. verbose option, filtering etc...) although implementing </div>
<div>them in py.countloc shouldn&#39;t be a hard thing to do.</div><div><br></div><div>Having said that, I find that the source line detection in py.countloc seems a bit more accurate. I initially had </div><div>trouble in deciding for example if docstrings should count as part of the source code or not (I ended including them).</div>
<div><br></div><div>In my specific case, I like something fast that reports what I need. If I want a ratio to be able to compare, this output</div><div>seems too much for me:</div><div><br></div><div><div>           number of testfiles 794</div>
<div> number of non-empty testlines 158805</div><div>               number of files 6906</div><div>     number of non-empty lines 1342471</div></div><div><br></div><div>Compared to:</div><div><br></div><div><div>Test lines   <span class="Apple-tab-span" style="white-space:pre">        </span>=     214669</div>
<div>Source lines <span class="Apple-tab-span" style="white-space:pre">        </span>=    1241449</div><div>Total lines <span class="Apple-tab-span" style="white-space:pre">        </span>=    1456118</div><div><br></div><div>Your test code is 17.29% of your source code</div>
</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
&gt;<br>
&gt;<br>
&gt; Thanks for an awesome an inspiring talk Ned!<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Alfredo Deza<br>
&gt;<br>
</div>&gt; _______________________________________________<br>
&gt; testing-in-python mailing list<br>
&gt; <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
&gt; <a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
<br>
</blockquote></div><br>