Popular recipes tagged "hotshot"http://code.activestate.com/recipes/tags/hotshot/popular/2009-02-20T22:35:07-08:00ActiveState Code Recipesquick Python profiling with hotshot (Python) 2009-02-20T22:35:07-08:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/ <p style="color: grey"> Python recipe 576656 by <a href="/recipes/users/4173505/">Trent Mick</a> (<a href="/recipes/tags/hotshot/">hotshot</a>, <a href="/recipes/tags/performance/">performance</a>, <a href="/recipes/tags/profile/">profile</a>). Revision 2. </p> <p>This is a quick snippet that I use occasionally to profile some pure-Python code, using <a href="http://docs.python.org/library/hotshot.html#module-hotshot"><code>hotshot</code></a>. Basically it is this:</p> <ol> <li>Put this <code>@hotshotit</code> decorator on the function you want to profile.</li> <li>Run your code through some representative paces. The result will be a <code>&lt;functionname&gt;.prof</code> in the current directory.</li> <li>Process the <code>.prof</code> file and print the top 20 hotspots with the given "show_stats.py" script.</li> </ol> <p>Props to <a href="http://blogs.activestate.com/toddw/">Todd</a> for slapping this code together.</p> <p>Hotshot <a href="http://docs.python.org/library/profile.html">is a little out of favour</a> now, so I should -- or Todd :) -- should really come up with an equivalent that uses <code>cProfile</code>.</p>