Profiling Your App

Status:Work in progress

TurboGears does not come with a built-in profiler, but an easy to use WSGI application profiler is just an easy_install away!

Installing repoze.profile

First, install it with easy_install:

easy_install -i repoze.profile

Next add it to your WSGI stack in in the config folder:

from repoze.profile.profiler import AccumulatingProfileMiddleware

def make_app(global_conf, full_stack=True, **app_conf):
     app = make_base_app(global_conf, full_stack=True, **app_conf)

     # Wrap your base TurboGears 2 application with custom middleware here
     app = AccumulatingProfileMiddleware(

     return app

Gathering Profile Data

Just fire up a browser (or functional test-runner like twill, ab (apache bench), or whatever). The repoze.profile middleware will profile everything above it in the WSGI stack.

Viewing Profile Data

There’s a built in web based view of your profile data. It should now be available at the location /__profile__ in your app. For explanation of the various columns shown on this page refer to python profiler docs

Some distros package the profiler separately. Make sure to install the python-profiler package as well.