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
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to