doc: update :func: to :py:func: for modern Sphinx.
[be.git] / doc / hacking.txt
index 54be7bcda1d0a489d337994e787299763877fb92..2684597a5ee12b5d2c292e0dcc6e1326b2da3461 100644 (file)
@@ -71,10 +71,18 @@ execution + childrens' times)::
     $ python -m cProfile -o profile be [command] [args]
     $ python -c "import pstats; p=pstats.Stats('profile'); p.sort_stats('cumulative').print_stats(20)"
 
-It's often useful to toss::
+If you want to find out who's calling your expensive function
+(e.g. :py:func:`libbe.util.subproc.invoke`), try::
+
+    $ python -c "import pstats; p=pstats.Stats('profile'); p.sort_stats('cumulative').print_callers(20)"
+
+You can also toss::
 
     import sys, traceback
     print >> sys.stderr, '-'*60, '\n', '\n'.join(traceback.format_stack()[-10:])
 
-into expensive functions (e.g. :func:`libbe.util.subproc.invoke`) if
-you're not sure why they're being called.
+into the function itself for a depth-first caller list.
+
+For a more top-down approach, try::
+
+    $ python -c "import pstats; p=pstats.Stats('profile'); p.sort_stats('cumulative').print_callees(20)"