[IronPython] -X:EnableProfiler and DLR hosting API
Mads Weitling
mads.weitling at gmail.com
Thu Aug 6 10:22:58 CEST 2009
Thank you for the answer :)
I found this article which tells me that a script can now enable the
profiler from within itself:
http://blogs.msdn.com/curth/archive/2009/04/11/profiler-part-ii-poor-man-s-code-coverage.aspx
<http://blogs.msdn.com/curth/archive/2009/04/11/profiler-part-ii-poor-man-s-code-coverage.aspx>So
I used that method instead, like this:
def begin_profiler():
import clr
clr.EnableProfiler(True)
clr.ClearProfilerData()
def end_profiler():
ticks_to_ms = 0.00001
clr.EnableProfiler(False)
# show top 20 sorted by exclusive time
for p in itertools.islice(sorted(filter(lambda item: item.Calls != 0,
clr.GetProfilerData(True)), key=lambda item: -item.InclusiveTime), 20):
print '%s\n%f\t%f\t%d' % (p.Name, p.InclusiveTime * ticks_to_ms,
p.ExclusiveTime * ticks_to_ms, p.Calls)
Seems to work very well :)
/Mads
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090806/9cc3b860/attachment.html>
More information about the Ironpython-users
mailing list