Improve duration/debug logging

This commit is contained in:
Richard Frith-Macdonald 2019-07-29 12:33:42 +01:00
parent 085c36c340
commit 46cf998afc
2 changed files with 24 additions and 11 deletions

View file

@ -1,3 +1,8 @@
2019-07-29 Richard Frith-Macdonald <rfm@gnu.org>
* SQLClient.m: Improve logging of cache queries to indicate that
the query was from the cache and whether it was a it or a miss.
2019-07-14 Wolfgang Lux <wolfgang.lux@gmail.com>
* SQLClient.h

View file

@ -3505,6 +3505,7 @@ static int poolConnections = 0;
NSMutableDictionary *md;
GSCache *c;
id toCache;
BOOL cacheHit;
if (rtype == 0) rtype = rClass;
if (ltype == 0) ltype = aClass;
@ -3530,6 +3531,7 @@ static int poolConnections = 0;
{
CacheQuery *a;
cacheHit = NO;
a = [CacheQuery new];
a->query = [stmt copy];
a->recordType = rtype;
@ -3552,17 +3554,10 @@ static int poolConnections = 0;
modes: queryModes];
}
result = [c objectForKey: stmt];
_lastOperation = GSTickerTimeNow();
if (_duration >= 0)
{
NSTimeInterval d;
d = _lastOperation - _lastStart;
if (d >= _duration)
{
[self debug: @"Duration %g for query %@", d, stmt];
}
}
}
else
{
cacheHit = YES;
}
if (seconds == 0)
@ -3585,6 +3580,19 @@ static int poolConnections = 0;
*/
result = [[result mutableCopy] autorelease];
}
_lastOperation = GSTickerTimeNow();
if (_duration >= 0)
{
NSTimeInterval d;
d = _lastOperation - _lastStart;
if (d >= _duration)
{
[self debug: @"Duration %g for cache-%@ query %@",
d, (YES == cacheHit) ? @"hit" : @"miss", stmt];
}
}
return result;
}