trace.py and coverage.py

Zooko zooko at zooko.com
Thu Jan 3 17:53:56 CET 2002


Greetings Pythonismos, Pythonismas, Gareth Rees, and Andrew Dalke:

I learned from Python-URL [1] that Gareth Rees [2] has published a code coverage 
tool called coverage.py [3].

On the web pages, Gareth compares coverage.py favorably against trace.py, but 
he appears to be using an old version of trace.py [4] from 1999 that is still 
sitting around on Andrew Dalke's FTP site.  Python comes with a newer version of 
trace.py [5] which has been modified by Skip Montanaro and then by me [6].

Here are the differences that I see right now between current trace.py and 
coverage.py:

1.  trace.py can do tracing as well as code coverage.  It can do either or both,
    and also has a "listfuncs" mode which just tracks which functions are 
    invoked at least once.

2.  coverage.py actually parses so as to annotate lines correctly, where trace.py
    just ignores blank lines and comments.

3.  coverage.py is much faster.  In my tests, coverage.py takes less than 
    2 seconds where trace.py takes 30 seconds.

4.  The usage interfaces are very different.  Not sure which, if either, is 
    better.

5.  coverage.py only keeps a binary measure of whether each line was invoked or 
    not, where trace.py counts how many times each line was invoked.

6.  coverage.py has a nice summary output that looks like this:

$ coverage.py -r -m foo.py bar.py
Name    Stmts   Exec  Cover  Missing
------------------------------------
foo        64     56    87%  23, 57, 85, 119, 125, 133, 137, 152
bar       105     90    86%  78-86, 237-246
------------------------------------
TOTAL     169    146    86%


Here are my ideas:

1.  Andrew Dalke removes that old version of trace.py from his FTP site!

2.  We consider merging the best features of these two tools and replacing the 
    standard distribution's trace.py with the new merged tool.

2.b. Who's this "we"?  Well, I understand the trace.py code already, so my 
    inclination would be to steal the "real parsing" feature from coverage.py 
    and add it to trace.py, and to try to optimize trace.py.  (By profiling it, 
    I suppose.  ;-))


Regards,

Zooko

---
             zooko.com
Security and Distributed Systems Engineering
---

[1] http://www.pythonware.com/daily/
[2] http://www.garethrees.org/
[3] http://www.garethrees.org/2001/12/04/python-coverage/
[4] ftp://starship.python.net/pub/crew/dalke/
[5] http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Tools/scripts/trace.py
[6] http://zooko.com/ [7]
[7] These footnotes are getting a little out of hand.  Footnote footnote!





More information about the Python-list mailing list