From cc3154a2c69396f72a5c0cc1795bc174a1d7b0d1 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 18 Jun 2017 03:37:01 -0700 Subject: [PATCH] Flag SQLite queries that take more than 100ms to complete, if SQL logging is enabled --- PBot/SQLiteLogger.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PBot/SQLiteLogger.pm b/PBot/SQLiteLogger.pm index 1cf10a7e..803f88bf 100644 --- a/PBot/SQLiteLogger.pm +++ b/PBot/SQLiteLogger.pm @@ -43,7 +43,10 @@ sub log_message { my $self = shift; my $now = gettimeofday; my $elapsed = $now - $self->{timestamp}; - $elapsed = sprintf '%10.4f', $elapsed; + if ($elapsed >= 0.100) { + $self->{pbot}->{logger}->log("^^^ SLOW SQL ^^^\n"); + } + $elapsed = sprintf '%10.3f', $elapsed; $self->{pbot}->{logger}->log("$elapsed : $self->{buf}"); $self->{timestamp} = $now; }