title: Python Profiling - Rollup function calls that are outside my code
body: <p>I am trying to profile our django unittests (if the tests are faster, we'll run 'em more often). I've ran it through python's built in cProfile profiler, producing a pstats file.</p>
  
  <p>However the signal to noise ration is bad. There are too many functions listed. Lots and lots of django internal functions are called when I make one database query. This makes it hard to see what's going on.</p>
  
  <p>Is there anyway I can "roll up" all function calls that are outside a certain directory?</p>
  
  <p>e.g. if I call a python function outside my directory, and it then calls 5 other functions (all outside my directory), then it should roll all those up, so it looks like there was only one function call, and it should show the cumulative time for the whole thing.</p>
  
  <p>This, obviously, is bad if you want to profile (say) Django, but I don't want to do that.</p>
  
  <p>I looked at the pstats.Stats object, but can't see an obvious way to modify this data.</p>