[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:


I used that method instead, like this:

def begin_profiler():
    import clr

def end_profiler():
    ticks_to_ms = 0.00001
    # 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 :)

-------------- 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