Just thought I'd share this quick middleware to log the time every views in a Django project takes to load.
I haven't found any that did quite what I wanted on django-snippets so I put together one.
Teh code to save somewhere and add to MIDDLEWARE_CLASSES:
import logging
import time
logger = logging.getLogger("views.timing")
class ViewTimingMiddleware(object):
def process_request(self, request):
self.time_started = time.time()
def process_response(self, request, response):
debug_time = time.time() - self.time_started
logging.debug("view %s loaded in %.2f secs", request.path, debug_time)
return response