diff options
| author | bkonkle | 2011-09-15 10:36:11 -0500 |
|---|---|---|
| committer | bkonkle | 2011-09-15 10:36:11 -0500 |
| commit | 717dc6815a9d4ddcd30efc17db11ade0f8f38354 (patch) | |
| tree | 5f3a3fceefe9bead41019c3216991337cc12fe6f /debug_toolbar/panels/profiling.py | |
| parent | ed9bca7c00f6f326842d79e843f678787fac8b15 (diff) | |
| download | django-debug-toolbar-717dc6815a9d4ddcd30efc17db11ade0f8f38354.tar.bz2 | |
Edited all of the panels to use the stats API and not override the content method
Diffstat (limited to 'debug_toolbar/panels/profiling.py')
| -rw-r--r-- | debug_toolbar/panels/profiling.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py index e08591a..8913621 100644 --- a/debug_toolbar/panels/profiling.py +++ b/debug_toolbar/panels/profiling.py @@ -1,9 +1,7 @@ from __future__ import division -from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _ from django.utils.safestring import mark_safe -from debug_toolbar.middleware import DebugToolbarMiddleware from debug_toolbar.panels import DebugPanel try: @@ -143,6 +141,7 @@ class ProfilingDebugPanel(DebugPanel): Panel that displays the Django version. """ name = 'Profiling' + template = 'debug_toolbar/panels/profiling.html' has_content = True def nav_title(self): @@ -178,16 +177,6 @@ class ProfilingDebugPanel(DebugPanel): out = self.profiler.runcall(view_func, *args, **view_kwargs) return out - def process_response(self, request, response): - self.profiler.create_stats() - self.stats = DjangoDebugToolbarStats(self.profiler) - if DJ_PROFILE_USE_LINE_PROFILER: - self.stats.line_stats = self.line_profiler.get_stats() - self.stats.calc_callees() - toolbar = DebugToolbarMiddleware.get_current() - toolbar.stats['profiling'] = self.stats - return response - def add_node(self, func_list, func, max_depth, cum_time=0.1): func_list.append(func) func.has_subfuncs = False @@ -199,14 +188,16 @@ class ProfilingDebugPanel(DebugPanel): func.has_subfuncs = True self.add_node(func_list, subfunc, max_depth, cum_time=cum_time) - def content(self): + def process_response(self, request, response): + self.profiler.create_stats() + self.stats = DjangoDebugToolbarStats(self.profiler) + if DJ_PROFILE_USE_LINE_PROFILER: + self.stats.line_stats = self.line_profiler.get_stats() + self.stats.calc_callees() + root = FunctionCall(self.stats, self.stats.get_root_func(), depth=0) func_list = [] self.add_node(func_list, root, 10, root.stats[3]/8) - context = self.context.copy() - context.update({ - 'func_list': func_list, - }) - return render_to_string('debug_toolbar/panels/profiling.html', context) + self.stats_record({'func_list': func_list}) |
