| 1 | {{{django.core.handlers.profiler-hotshot}}} provides profiling support for Django when using mod_python. Here's a similar solution for the internal development webserver. |
| 2 | |
| 3 | Apply the included patch to {{{django/core/management.py}}} and start Django with {{{manage.py runserver}}}. Each request will create a {{{.prof}}} file in your {{{/tmp}}} directory. You can then open a Python shell and print the statistics: |
| 4 | |
| 5 | {{{ |
| 6 | >>> import hotshot.stats |
| 7 | >>> stats = hotshot.stats.load("stones.prof") |
| 8 | >>> stats.strip_dirs() |
| 9 | >>> stats.sort_stats('time', 'calls') |
| 10 | >>> stats.print_stats(20) |
| 11 | }}} |