How to profile django application with respect to execution time?

Yugal Jindle picture Yugal Jindle · May 29, 2012 · Viewed 8.9k times · Source

My Django application is insanely slow, I want to figure out what is taking time :

I tried Django-debug-toolbar but was unable to find a panel that can give me the break-up of the load time.

My requirements:

  • A stack-trace type output with time of execution for each module called to render the page.
  • I want to realize what part of the whole page rendering process is taking the time ?
  • Also, what part is consuming how much CPU [ MOST IMPORTANT ] ?

Can django-debug-toolbar do that ? [ What panel ? ]

Any other django-app that can do that ?

Answer

ppetrid picture ppetrid · Nov 26, 2012

django-debug-toolbar 2.0

By default, django-debug-toolbar 2.0 includes 'debug_toolbar.panels.profiling.ProfilingPanel' in the settings DEBUG_TOOLBAR_PANELS. You can view this profiling information by ticking the "Profiling" checkbox in the toolbar and refreshing the page.

Old versions of django-debug-toolbar:

You can try the profiling panel of the django-debug-toolbar (make sure you use the application's latest version from github). Enable the panel like so in your settings.py:

DEBUG_TOOLBAR_PANELS = (
  'debug_toolbar.panels.version.VersionDebugPanel',
  'debug_toolbar.panels.timer.TimerDebugPanel',
  'debug_toolbar.panels.profiling.ProfilingDebugPanel',
)

This existence of this panel is not documented on the readme of django-debug-toolbar; that's why I answer here in the first place.