[enh] Add Server-Timing header (#1637)

Server Timing specification: https://www.w3.org/TR/server-timing/

In the browser Dev Tools, focus on the main request, there are the responses per engine in the Timing tab.
This commit is contained in:
Alexandre Flament 2019-07-17 10:38:45 +02:00 committed by GitHub
parent cfcbc3a5c3
commit 554a21e1d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 15 deletions

View file

@ -136,6 +136,7 @@ class ResultContainer(object):
self._ordered = False
self.paging = False
self.unresponsive_engines = set()
self.timings = []
def extend(self, engine_name, results):
for result in list(results):
@ -319,3 +320,13 @@ class ResultContainer(object):
def add_unresponsive_engine(self, engine_error):
self.unresponsive_engines.add(engine_error)
def add_timing(self, engine_name, engine_time, page_load_time):
self.timings.append({
'engine': engines[engine_name].shortcut,
'total': engine_time,
'load': page_load_time
})
def get_timings(self):
return self.timings