<br><br><div class="gmail_quote">On Sat, Oct 16, 2010 at 1:12 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 Sat, 2010-10-16 at 12:11 -0400, Alfredo Deza wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Oct 15, 2010 at 8:23 PM, Ronny Pfannschmidt<br>
&gt; &lt;<a href="mailto:Ronny.Pfannschmidt@gmx.de">Ronny.Pfannschmidt@gmx.de</a>&gt; wrote:<br>
&gt;<br>
&gt;         On Sun, 2010-02-28 at 16:38 -0500, Alfredo Deza wrote:<br>
&gt;         &gt; After Ned Batchelder&#39;s talk in Python I spent a few minutes<br>
&gt;         talking<br>
&gt;         &gt; about how nice it is to have as much (or even more!) test<br>
&gt;         code lines<br>
&gt;         &gt; than source code lines.<br>
&gt;         &gt;<br>
&gt;         &gt; I have put together a small script that will count the lines<br>
&gt;         of code<br>
&gt;         &gt; in a given directory and will compare them to your test code<br>
&gt;         lines<br>
&gt;         &gt; with a nice output (e.g. percentage, total lines, lines per<br>
&gt;         file<br>
&gt;         &gt; etc...).<br>
&gt;         &gt;<br>
&gt;         &gt; Ideally, this could become a plugin for Nose (or py.test),<br>
&gt;         but for<br>
&gt;         &gt; now, it will create an executable symlink so you can run it<br>
&gt;         anywhere.<br>
&gt;         &gt;<br>
&gt;         &gt; The project page: <a href="http://code.google.com/p/pygora/" target="_blank">http://code.google.com/p/pygora/</a><br>
&gt;         &gt;<br>
&gt;         &gt; I am using distribute to package Pygora, you can install it<br>
&gt;         by:<br>
&gt;         &gt;<br>
&gt;         &gt;         sudo easy_install pygora<br>
&gt;         &gt;<br>
&gt;         &gt; And, if you were not wondering already, the name comes from<br>
&gt;         a *goat*:<br>
&gt;         &gt; Pygora Goat is a cross between the Pygmy Goat and the Angora<br>
&gt;         Goat that<br>
&gt;         &gt; produces three distinct kinds of fleece and has the smaller<br>
&gt;         size of<br>
&gt;         &gt; the Pygmy.<br>
&gt;         &gt; Source: Wikipedia<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; Pygora could do better in telling what lines to count with a<br>
&gt;         nice<br>
&gt;         &gt; regex, but this first release will get you an idea,<br>
&gt;         enhancements will<br>
&gt;         &gt; follow.<br>
&gt;<br>
&gt;<br>
&gt;         you might want to take a look at py.countloc which is shipped<br>
&gt;         by py (and<br>
&gt;         will be in pycmd in future)<br>
&gt;<br>
&gt;         py.countloc provides way better numbers (imho)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Since I had py.test installed I tried out py.countloc, and I have a<br>
&gt; few comments...<br>
&gt;<br>
&gt;<br>
&gt; The idea behind pygora is to have a comparison ratio, to know where<br>
&gt; your test line numbers<br>
&gt; are related to those of your source code, this is not provided by<br>
&gt; py.countloc<br>
&gt;<br>
&gt;<br>
&gt; In the latest pygora version (you have actually replied to the first<br>
&gt; announcement dated in February)<br>
</div></div>my misstake, i was in the middle of working trough the backlog of the<br>
ml, and mindlessly replied to the first mail instead of finding the<br>
latest one<br></blockquote><div><br></div><div>no big deal :)</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; speed was improved a lot, and in fact after benchmarking both tools<br>
&gt; pygora takes almost<br>
&gt; half the time to go through a path and get the metrics.<br>
&gt;<br>
&gt;<br>
&gt; For example, in a directory with around 1,5 million lines of code<br>
&gt; these are the times I got (best out of 3 runs):<br>
&gt;<br>
&gt;<br>
&gt; py.countloc  4.04s user 0.50s system 99% cpu 4.572 total<br>
&gt;<br>
&gt;<br>
&gt; pygora  2.52s user 0.66s system 97% cpu 3.253 total<br>
</div>interesting timings, i think py.countloc was only optimized for accurate<br>
numbers, not raw speed, i&#39;ll take a look at that once my todo is shorted<br>
out<br></blockquote><div><br></div><div>Well, I think the speed improvements are a by-product of refactoring the previous version.</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; There is also no way to tell py.countloc to avoid printing *every*<br>
&gt; single file it is counting. This is specially<br>
&gt; annoying for 1.5m lines of code, also, no way of filtering or<br>
&gt; excluding certain files.<br>
&gt;<br>
&gt;<br>
&gt; All of those options are available with pygora (e.g. verbose option,<br>
&gt; filtering etc...) although implementing<br>
&gt; them in py.countloc shouldn&#39;t be a hard thing to do.<br>
&gt;<br>
&gt;<br>
&gt; Having said that, I find that the source line detection in py.countloc<br>
&gt; seems a bit more accurate. I initially had<br>
&gt; trouble in deciding for example if docstrings should count as part of<br>
&gt; the source code or not (I ended including them).<br>
</div>thats why i wanted to point you at it after trying a easy_installed<br>
pygora<br>
<div class="im">&gt;<br>
&gt;<br>
&gt; In my specific case, I like something fast that reports what I need.<br>
&gt; If I want a ratio to be able to compare, this output<br>
&gt; seems too much for me:<br>
&gt;<br>
&gt;<br>
&gt;            number of testfiles 794<br>
&gt;  number of non-empty testlines 158805<br>
&gt;                number of files 6906<br>
&gt;      number of non-empty lines 1342471<br>
&gt;<br>
&gt;<br>
&gt; Compared to:<br>
&gt;<br>
&gt;<br>
&gt; Test lines    =     214669<br>
&gt; Source lines =    1241449<br>
&gt; Total lines =    1456118<br>
&gt;<br>
&gt;<br>
&gt; Your test code is 17.29% of your source code<br>
&gt;<br>
</div>i guess i&#39;m more interested in the other stats,<br>
usually the ratio of test lines vs tested code lines<br>
isn&#39;t that interesting (i tend to have more test lines than code lines)<br>
whats more interesting to me is the ratio of code/branch coverage<br></blockquote><div><br></div><div>you mention &quot;ratio&quot; but I just don&#39;t see any ratio with py.countloc, unless</div><div>I am missing something...</div>
<div><br></div><div>I&#39;m also confused here about &quot;code/branch coverage&quot;. What do you mean? this is *not* </div><div>a coverage tool, it just counts lines and compares them. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class="h5"><br>
&gt;<br>
&gt;<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; Thanks for an awesome an inspiring talk Ned!<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; --<br>
&gt;         &gt; Alfredo Deza<br>
&gt;         &gt;<br>
&gt;<br>
&gt;         &gt; _______________________________________________<br>
&gt;         &gt; testing-in-python mailing list<br>
&gt;         &gt; <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
&gt;         &gt; <a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br>