From 9d0f492d8a999c1a3eb6525b0ae72bbbcaad4279 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 30 Aug 2022 11:36:58 +0300 Subject: Remove "with Bench ..." calls "with Bench" instruments how long a function takes and generates time reports on as INFO logs. This should be done on a developer server. Should the log level be low enough, this bench marks will generate a lot of noise. Instrumentation should be done during development. * wqflask/base/data_set.py (create_datasets_list): Remove "with Bench...". * wqflask/db/call.py (fetchone): Ditto. (fetchall): Ditto. (gn_server): Ditto. * wqflask/wqflask/gsearch.py (GSearch.__init__): Ditto. * wqflask/wqflask/marker_regression/display_mapping_results.py (DisplayMappingResults.__init__): Ditto. * wqflask/wqflask/marker_regression/run_mapping.py (RunMapping.__init__): Ditto. * wqflask/wqflask/update_search_results.py (GSearch.__init__): Ditto. * wqflask/wqflask/views.py (search_page): Ditto. (heatmap_page): Ditto. (mapping_results_page): Ditto. --- wqflask/db/call.py | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'wqflask/db') diff --git a/wqflask/db/call.py b/wqflask/db/call.py index a6bbda54..c27e0326 100644 --- a/wqflask/db/call.py +++ b/wqflask/db/call.py @@ -11,13 +11,10 @@ except: import urllib2 import json from utility.tools import USE_GN_SERVER, LOG_SQL, GN_SERVER_URL -from utility.benchmark import Bench from utility.logger import getLogger logger = getLogger(__name__) -# from inspect import stack - def fetch1(query, path=None, func=None): """Fetch one result as a Tuple using either a SQL query or the URI @@ -41,11 +38,10 @@ def fetchone(query): original fetchone, but with logging) """ - with Bench("SQL", LOG_SQL): - def helper(query): - res = g.db.execute(query) - return res.fetchone() - return logger.sql(query, helper) + def helper(query): + res = g.db.execute(query) + return res.fetchone() + return logger.sql(query, helper) def fetchall(query): @@ -53,23 +49,21 @@ def fetchall(query): original fetchall, but with logging) """ - with Bench("SQL", LOG_SQL): - def helper(query): - res = g.db.execute(query) - return res.fetchall() - return logger.sql(query, helper) + def helper(query): + res = g.db.execute(query) + return res.fetchall() + return logger.sql(query, helper) def gn_server(path): """Return JSON record by calling GN_SERVER """ - with Bench("GN_SERVER", LOG_SQL): - res = () - try: - res = urllib.request.urlopen(GN_SERVER_URL + path) - except: - res = urllib2.urlopen(GN_SERVER_URL + path) - rest = res.read() - res2 = json.loads(rest) - return res2 + res = () + try: + res = urllib.request.urlopen(GN_SERVER_URL + path) + except: + res = urllib2.urlopen(GN_SERVER_URL + path) + rest = res.read() + res2 = json.loads(rest) + return res2 -- cgit v1.2.3