Stats: request count is a percentage

This commit is contained in:
Alexandre Flament 2024-01-27 11:41:57 +00:00 committed by Emilien Devos
parent ae1e73e871
commit 3c37cf4e8d
2 changed files with 10 additions and 0 deletions

View file

@ -92,6 +92,9 @@ def initialize(engine_names=None, enabled=True):
histogram_width = 0.1
histogram_size = int(1.5 * max_timeout / histogram_width)
# global
counter_storage.configure('search', 'count', 'sent')
# engines
for engine_name in engine_names or engines:
# search count
@ -242,6 +245,11 @@ def get_engines_stats(engine_name_list):
list_time.append(stats)
# request_count (per engine) is a percentage of the total number of requests
total_request_count = counter('search', 'count', 'sent')
for stats in list_time:
stats['request_count'] = int(round(stats['request_count'] * 100 / total_request_count, 0))
return {
'time': list_time,
'max_time': math.ceil(max_time_total or 0),

View file

@ -89,6 +89,8 @@ class Search:
# max of all selected engine timeout
default_timeout = 0
counter_inc('search', 'count', 'sent')
# start search-request for all selected engines
for engineref in self.search_query.engineref_list:
processor = PROCESSORS[engineref.name]