How can I measure time taken for template generation?
I know i can collect time Context.render() takes but can i do it unobtrusive way? Something like Page Stats Middleware do for Python and DB time... But split Python time to code/view time and template time?
views:
24answers:
1
+1
A:
You could swap old render method to your own like this:
old_render = Context.render
def new_render(self, *args, **kwargs):
# do some profiling
old_render(self, *args, **kwargs)
# do some profiling
Context.render = new_render
This shouldn't be very obtrusive and you can remove it anytime you won't - it doesn't change interface.
I don't believe you can use middleware, because middleware works before request is passed to a view - and you render a template inside a view.
gruszczy
2010-07-22 11:08:35
you are right... my bad ) too many coffee i think.
NilColor
2010-07-22 11:10:54
Hope this helps :-)
gruszczy
2010-07-22 11:20:03