profiling-fix-2

This commit is contained in:
Untone 2024-02-21 18:03:02 +03:00
parent be9f62eb76
commit 74e639737e

View File

@ -57,7 +57,7 @@ def after_cursor_execute(conn, cursor, statement, parameters, context, executema
elapsed = time.time() - conn._query_start_time elapsed = time.time() - conn._query_start_time
del conn._query_start_time del conn._query_start_time
if elapsed > 0.2: # Adjust threshold as needed if elapsed > 0.2: # Adjust threshold as needed
print(f"{'*' * math.floor(elapsed)} {elapsed:.3f} seconds to execute.") logger.debug(f"{'*' * math.floor(elapsed)} {elapsed:.3f} seconds to execute.")
# Profile the query if execution time exceeds the threshold # Profile the query if execution time exceeds the threshold
profiler = profile_sqlalchemy_queries(threshold=0.2)(cursor.execute) profiler = profile_sqlalchemy_queries(threshold=0.2)(cursor.execute)
profiler(statement, parameters) profiler(statement, parameters)