Thank you for the answer :)<div><br></div><div>I found this article which tells me that a script can now enable the profiler from within itself:</div><div><br></div><div><a href="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</a></div>
<div><br></div><div><a href="http://blogs.msdn.com/curth/archive/2009/04/11/profiler-part-ii-poor-man-s-code-coverage.aspx"></a>So I used that method instead, like this:</div><div><br></div><div><div>def begin_profiler():</div>
<div>    import clr</div><div>    clr.EnableProfiler(True)</div><div>    clr.ClearProfilerData()</div><div><br></div><div>def end_profiler():</div><div>    ticks_to_ms = 0.00001</div><div>    clr.EnableProfiler(False)        </div>
<div>    # show top 20 sorted by exclusive time</div><div>    for p in itertools.islice(sorted(filter(lambda item: item.Calls != 0, clr.GetProfilerData(True)), key=lambda item: -item.InclusiveTime), 20):</div><div>        print &#39;%s\n%f\t%f\t%d&#39; % (p.Name, p.InclusiveTime * ticks_to_ms, p.ExclusiveTime * ticks_to_ms, p.Calls)</div>
<div><br></div><div>Seems to work very well :)</div><br>/Mads
</div>