From a836aa5dedecf070be0d8e8584285be2b57f6494 Mon Sep 17 00:00:00 2001 From: James Socol Date: Fri, 3 Feb 2012 10:23:09 -0500 Subject: [PATCH] [bug 723930] Time search per engine. --- apps/search/views.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/search/views.py b/apps/search/views.py index 7e9006e4e17..8ccdff2d7b4 100644 --- a/apps/search/views.py +++ b/apps/search/views.py @@ -46,6 +46,10 @@ def jsonp_is_valid(func): def search(request, template=None): """Performs search or displays the search form.""" + # Time ES and Sphinx separate. See bug 723930. + # TODO: Remove this once Sphinx is gone. + start = time.time() + # JSON-specific variables is_json = (request.GET.get('format') == 'json') callback = request.GET.get('callback', '').strip() @@ -419,6 +423,12 @@ def search(request, template=None): .strftime(expires_fmt) results_.set_cookie(settings.LAST_SEARCH_COOKIE, urlquote(cleaned['q']), max_age=3600, secure=False, httponly=False) + + # Send timing information for each engine. Bug 723930. + # TODO: Remove this once Sphinx is gone. + dt = (time.time() - start) * 1000 + statsd.timing('search.%s.view' % engine, int(dt)) + return results_