Code Yarns β€πŸ‘¨β€πŸ’»
Tech Blog ❖ Personal Blog

How to use RunSnakeRun to visualize Python profiler statistics

πŸ“… 2013-May-12 ⬩ ✍️ Ashwin Nanjappa ⬩ πŸ“š Archive

It is really easy to profile a Python program. But, it is not straightforward to determine the different bottlenecks in the program by looking at the profiler output. A visualization of the profiler output makes it really convenient to examine the different sources of bottleneck in the program. Β One way to visualize the profiler output is to use RunSnakeRun.

  1. RunSnakeRun ships as a Python module. But, before installing it, install the packages it is dependent on: python-profiler, python-wxgtk2.8 and python-setuptools.

  2. Install RunSnakeRun from PyPI using easy_install:

$ sudo easy_install SquareMap RunSnakeRun
  1. Profile your Python program and dump the statistics to a file, say foostats.

  2. Open the profiler statistics file with RunSnakeRun:

$ runsnake foostats

RunSnakeRun shows a tabular view of the profiler statistics, similar to the output of cProfile. It also shows a squaremap visualization of the call tree. This makes it really convenient to drill down to the various bottlenecks in the program.

Tried with: RunSnakeRun 2.0.2b1, Python 2.7.3 and Ubuntu 12.04 LTS