Popular recipes tagged "profile" but not "database"http://code.activestate.com/recipes/tags/profile-database/2012-10-12T23:40:55-07:00ActiveState Code RecipesParse profile (Python)
2012-10-12T23:40:55-07:00Jason Friedmanhttp://code.activestate.com/recipes/users/4183835/http://code.activestate.com/recipes/578280-parse-profile/
<p style="color: grey">
Python
recipe 578280
by <a href="/recipes/users/4183835/">Jason Friedman</a>
(<a href="/recipes/tags/parse/">parse</a>, <a href="/recipes/tags/profile/">profile</a>, <a href="/recipes/tags/shell/">shell</a>).
Revision 3.
</p>
<pre class="prettyprint"><code>export VAR1=foo
export VAR2=bar
export VAR3=$VAR1$VAR2
export VAR4=${VAR1}$VAR2
export VAR5=${VAR1}indent
export VAR6="text${VAR1} " # With embedded spaces and a comment
export VAR7='${VAR4}' # Leave text within tics as-is
</code></pre>
<p>will be read as:</p>
<pre class="prettyprint"><code>{'VAR1': 'foo',
'VAR2': 'bar',
'VAR3': 'foobar',
'VAR4': 'foobar',
'VAR5': 'fooindent',
'VAR6': 'textfoo ',
'VAR7': '${VAR4}'}
</code></pre>
Profile decorator (Python)
2011-08-02T19:08:58-07:00Giampaolo RodolĂ http://code.activestate.com/recipes/users/4178764/http://code.activestate.com/recipes/577817-profile-decorator/
<p style="color: grey">
Python
recipe 577817
by <a href="/recipes/users/4178764/">Giampaolo RodolĂ </a>
(<a href="/recipes/tags/profile/">profile</a>, <a href="/recipes/tags/profiling/">profiling</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>A decorator for profiling a function which prints profiling results to stdout.
This was originally proposed as a patch for inclusion into python stdlib:</p>
<p><a href="http://bugs.python.org/issue9285" rel="nofollow">http://bugs.python.org/issue9285</a></p>
<p>Note that on certain Linux systems pstats module isn't available, despite it is supposed to be part of Python stdlib. On my Ubuntu box I had to run "sudo apt-get install python-profile" first.</p>
quick 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><functionname>.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>