From 0c888687fa0db8b002150bc42beb5da3d7a78655 Mon Sep 17 00:00:00 2001 From: Oleg Silkin Date: Mon, 22 Jul 2019 11:10:55 -0400 Subject: [PATCH] Adds benchmarking to request handling --- src/handles.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/handles.py b/src/handles.py index 737687e..2dad791 100644 --- a/src/handles.py +++ b/src/handles.py @@ -76,6 +76,7 @@ async def process_json(app, body: dict) -> dict: clean_input_params(params) logger.debug(f'Received Method {method}, params: {params}') try: + start = time.time() if asyncio.iscoroutinefunction(METHODS[method]): result = await METHODS[method](app, params) else: @@ -87,6 +88,9 @@ async def process_json(app, body: dict) -> dict: response['error'] = make_error('INVALID_PARAMS', err) else: response['error'] = make_error('INTERNAL', err) + finally: + end = time.time() + logger.debug(f'Time taken to process {method}: {end - start} secs') else: response['error'] = make_error('METHOD_NOT_FOUND') return response