<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Matt,<div>  OK.  Thanks a lot for your advice on this.  This looks like a perfect place to start!</div><div><br></div><div>Eric<br><div><div>On May 3, 2012, at 1:44 PM, Matthew Turk wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi Eric,<br><br>On Thu, May 3, 2012 at 1:41 PM, Eric Hallman <<a href="mailto:hallman@txcorp.com">hallman@txcorp.com</a>> wrote:<br><blockquote type="cite">Is there a standard or best methodology for tracking python code<br></blockquote><blockquote type="cite">performance?  I see in the intertubes that one can use the time module, or<br></blockquote><blockquote type="cite">timeit or other things.  How about memory usage?  Or is this typically<br></blockquote><blockquote type="cite">handled by debugging tools?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">What I really want to do is isolate logjams in python code by function call<br></blockquote><blockquote type="cite">etc. in a fairly non-intrusive way.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks for any advice.<br></blockquote><br>If you're using yt, there are three methods you can call upon.  If<br>not, I'd recommend using the cProfile module as a start, moving on to<br>what was kernprof and is now lineprof, and ending at Bryan<br>O'Sullivan's recent statprof.  For visualizing, "pip install jinja2<br>pyprof2html" will get you pyprof2html, which turns a cProfile file to<br>HTML which is nicely viewable.<br><br>In yt, performance timers (written by Stephen) can help, but for very<br>simple stuff:<br><br>with parallel_profile("some_prefix"):<br>    some_expensive_operation()<br><br>will output .cprof files with processor IDs in them, which can be run<br>through pyprof2html.  For memory, get_memory_usage() is a yt function<br>that gives you the current resident size of your PID.<br><br>There are a few more memory debuggers, but thye get a bit tricky and I<br>can't comment on their success-rates.<br><br>-Matt<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">Eric<br></blockquote><blockquote type="cite">--<br></blockquote><blockquote type="cite">Eric Hallman<br></blockquote><blockquote type="cite">Tech-X Corporation               <a href="mailto:hallman@txcorp.com">hallman@txcorp.com</a><br></blockquote><blockquote type="cite">5621 Arapahoe Ave, Suite A       Phone: (720) 254-5833<br></blockquote><blockquote type="cite">Boulder, CO 80303                Fax:   (303) 448-7756<br></blockquote><blockquote type="cite">--<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">yt-users mailing list<br></blockquote><blockquote type="cite"><a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br></blockquote><blockquote type="cite"><a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br></blockquote><blockquote type="cite"><br></blockquote>_______________________________________________<br>yt-users mailing list<br><a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br></div></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>-- <br>Eric Hallman<br>Tech-X Corporation               hallman<a href="mailto:kruger@txcorp.com">@txcorp.com</a><br>5621 Arapahoe Ave, Suite A       Phone: (720) 254-5833<br>Boulder, CO 80303                Fax:   (303) 448-7756<br>--</div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>