summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-01-08 20:52:34 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-01-18 08:30:22 (GMT)
commit43e2a874f0d357455abf594110c9b4ead2a06883 (patch)
tree6f35d2c07b051c423a4f637c424fd2cdd45ed5fa
parent7d142556de21c958016d90cb0ab08cc442b3e989 (diff)
downloadcombo-wip/performances.zip
combo-wip/performances.tar.gz
combo-wip/performances.tar.bz2
"perf middleware"wip/performances
-rw-r--r--combo/middleware.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/combo/middleware.py b/combo/middleware.py
index 1300aaf..f47b48d 100644
--- a/combo/middleware.py
+++ b/combo/middleware.py
@@ -23,12 +23,21 @@ def get_request():
return _requests.get(threading.current_thread())
+import time
+
+def tt(msg, request=None): # trace_time
+ if request is None:
+ request = get_request()
+ print time.time()-request.t0, msg
+
class GlobalRequestMiddleware(object):
def process_request(self, request):
_requests[threading.current_thread()] = request
+ request.t0 = time.time()
request.cache = {}
def process_response(self, request, response):
if threading.current_thread() in _requests:
del _requests[threading.current_thread()]
+ print time.time() - request.t0
return response