Installing WxPython and RunSnakeRun on Mac OSX 10.9

2014-05-28 09:37:42 -0400

I just posted about my Ctrl-C strategy for profiling and now I'm going to completely flip-flop and explain how I installed RunSnakeRun, a way to visualize the output of Python's cProfile. The Ctrl-C way of profiling worked really well for optimizing append performance of my time series storage library, but doesn't work so great for profiling things that are already very fast (on the order of milliseconds) and need to be faster.

For that, RunSnakeRun worked really well. RunSnakeRun gives you a nice rectangle chart showing in which functions your program spends most of its time.

{% picture wp/uploads/2014/05/Screen-Shot-2014-05-28-at-9.27.01-AM-800x499.png %}

To install RunSnakeRun on Mac OSX, you'll need Homebrew and PIP. You can install it like this:

$ brew install wxpython --python --devel
$ pip install SquareMap RunSnakeRun

Next, you'll need to export a pstats database with your profiler information. Use cProfile to do this. For TsTables, you can run the benchmark with profiling information like this:

import cProfile
import tstables

cProfile.run('tstables.Benchmark.main()','tstables.profile')

This will create a tstables.profile file in the current directory, which you can open with RunSnakeRun. Start RunSnakeRun by running runsnake  (assuming that PIP's bin folder is in your path).