Add very simple benchmarking support when debugging

This commit is contained in:
TheAMM
2019-04-08 19:13:38 +03:00
parent db83989d5d
commit b0c51e9fa0
2 changed files with 42 additions and 0 deletions

View File

@@ -34,6 +34,19 @@ def create_app(config):
request.headers['Expires'] = '0'
return request
# Add a timer header to the requests when debugging
# This gives us a simple way to benchmark requests off-app
import time
@app.before_request
def timer_before_request():
flask.g.request_start_time = time.time()
@app.after_request
def timer_after_request(request):
request.headers['X-Timer'] = time.time() - flask.g.request_start_time
return request
else:
app.logger.setLevel(logging.WARNING)