How to profile


This document describes how to run various profiling services in Komodo. There are currently two ways to profile Komodo, each having strenghts and weakness. These are the javascript profiler, and the pyxpcom trace profiler.

Unfortunately no method to profile all of JavaScript and Python together is available, though generally if your profiling JavaScript, you will inadvertingly be profiling all calls that go through XPCOM (though you won't see the underlying Python/C++ functions).

JavaScript Profiler

Use the ko/profiler JS module. Profiles are dumped to your profile folder. To open them use Cleopatra.

To record named profiles you need to set the profilerEnabledName string pref.

To record unnamed profiles you need to first call require("ko/profiler").enable().

Python Profiler

You can profile python using cProfile

import cProfile
pr = cProfile.Profile()

Python Memory Profiler

  • Compile Meliae using Python 2.7.8 (UCS-2) and Cython (pyenv is a good tool for this).
  • Copy the compiled library to a path that Komodo's internal python process uses (print sys.path inside Komodo to find out)
  • Generate a dump with:
import meliae.scanner

PyXPCOM Trace Profiling

To turn on the trace profiling, do::


This turns on the code profiler in python, and wraps all python xpcom objects in order to profile calls over xpcom. Upon shutting down Komodo, the profiler will print out a summary of the executed Python/XPCOM code.