Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to profile django application with respect to execution time?

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 ?

like image 846
Yugal Jindle Avatar asked May 29 '12 13:05

Yugal Jindle


People also ask

What does Django Startproject do?

The startproject will create the main project directory, while the startapp will create the app directory. Both are also been passed a name to be used in generation. The startproject is the first command run when creating a new project, while the startapp is run inside the new project directory.

How do I debug Django app?

If you want to debug Django using PTVS, you need to do the following: In Project settings - General tab, set "Startup File" to "manage.py", the entry point of the Django program. In Project settings - Debug tab, set "Script Arguments" to "runserver --noreload". The key point is the "--noreload" here.


1 Answers

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.

like image 85
ppetrid Avatar answered Sep 29 '22 11:09

ppetrid