trace.py and coverage.py
Zooko
zooko at zooko.com
Thu Jan 3 13:26:05 EST 2002
I, Zooko, wrote the lines prepended with "> >":
Gareth Rees <gdr at ravenbrook.com> wrote:
>
> >The usage interfaces are very different. Not sure which, if either,
> >is better.
>
> In the coverage.py model you run tests, generate a report, use the
> report to direct your testing activity to fruitful locations in the
> code, generate a new report based on all the testing so far, and so
> on.
I believe trace.py allows the same usage.
> >coverage.py is much faster. In my tests, coverage.py takes less
> >than 2 seconds where trace.py takes 30 seconds.
>
> It's obvious where the bottleneck is in a tracing or coverage
> application: it's the function that you pass to sys.settrace. Here's
> the tracing function from coverage.py:
>
> c = {}
> def t(f, x, y):
> c[(f.f_code.co_filename, f.f_lineno)] = 1
> return t
I think you are right. Here's the function in trace.py:
def localtrace_count(self, frame, why, arg):
if why == 'line':
(filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame)
key = (filename, lineno,)
self.counts[key] = self.counts.get(key, 0) + 1
return self.localtrace
I vaguely recall changing from `f.f_code.co_filename' to `inspect.getframeinfo()'
because I thought I had encountered some mysterious problems with the `f_'
members.
I'll experiment with coverage.py and see if it handles Mojo Nation as well as
trace.py does.
Regards,
Zooko
---
zooko.com
Security and Distributed Systems Engineering
---
More information about the Python-list
mailing list