django-depiction

Tooling for profiling Django applications, inspired by David Cramer
Download

django-depiction Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Publisher Name:
  • Travis Chase and Rob Madole
  • Publisher web site:
  • http://localbase.com

django-depiction Tags


django-depiction Description

Tooling for profiling Django applications, inspired by David Cramer django-depiction is a plugin for profiling Django applications.Developer commentsWe were looking for profiling tools as we worked on improving the performance of one of our Django applications. We didn't find anything that tripped our triggers so this was created.It's some tooling, right now Middleware and a decorator, that allows you to quickly see some profile data and optionally export a .kgrind file suitable for viewing in KDE's KCacheGrind.InstallationYou need Django for this to work, if you need help with that head hereUsing Pip:pip install django-depictionOr:pip install -e git+http://github.com/robmadole/django-depiction.git#egg=djangodepictionSettingsEdit your Django settings, adding this to the MIDDLEWARE_CLASSES.MIDDLEWARE_CLASSES = ( ... 'depiction.middleware.ProfilerMiddleware',)Add the following settingPROFILING = TrueAnd make sure that your internal IP address is presentINTERNAL_IPS = ('127.0.0.1',)Middleware usageYou can trigger output by adding prof to the query string. For example, say this was a URL in your applicationhttp://127.0.0.1:8000/lumberjacks/listTo get some profile data on this pagehttp://127.0.0.1:8000/lumberjacks/list?profIf you already have a query string, add to it like thishttp://127.0.0.1:8000/lumberjacks/list?playsDressup=True&profTo filter by filenamehttp://127.0.0.1:8000/lumberjacks/list?playsDressup=True&prof=django/templateTo get your profile data as a kgrind filehttp://127.0.0.1:8000/lumberjacks/list?prof&grindNote: You will need to make sure prof is also set. This will trigger a "Save As.." file download of the profile data to use in KCacheGrind.Creating kgrind filesThere is a project called KCacheGrind that provides a GUI for analyzing profile data. You are on your own to get KCacheGrind installed, but once you do you will need a .kgrind file to look at.You can do this with a decorator. Here is a Django View example.from django.template.loader import render_to_responsefrom depiction.decorator import kgrindfrom lumberjacks.models import *@kgrind('listing_lumberjacks.kgrind')def list_lumberjacks(request): return render_to_response('lumberjacks/list.html', { men': Lumberjacks.objects.all()})This will create a listing_lumberjacks.kgrind file in the current working directory. You can then load this into KCacheGrind. Requirements: · Python · Django What's New in This Release: · Adding the ability to download a kgrind file with a query string param.


django-depiction Related Software