o a start to make statistics work

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@14860 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
dwetzel 2002-10-28 19:57:10 +00:00
parent 8c729f6eb8
commit 783d404d07
5 changed files with 128 additions and 11 deletions

View file

@ -1988,6 +1988,7 @@ selfLockn,
LOGObjectFnStart();
session=[self _createSessionForRequest:aRequest];
NSDebugMLLog(@"sessions",@"session:%@",session);
[_statisticsStore _applicationCreatedSession:session];
LOGObjectFnStop();
return session;
};
@ -2512,6 +2513,9 @@ selfLockn,
//OK
GSWResponse* response=nil;
GSWRequestHandler* requestHandler=nil;
NSDate* reqStartDate=nil;
NSTimeInterval timeInterval = 0.0;
LOGObjectFnStart();
#ifndef NDEBUG
[self lock];
@ -2519,6 +2523,8 @@ selfLockn,
[self unlock];
#endif
reqStartDate = [NSDate date];
response = [self checkAppIfRefused:aRequest];
if (!response)
{
@ -2539,6 +2545,11 @@ selfLockn,
response=[requestHandler handleRequest:aRequest];
NSDebugMLLog(@"requests",@"sessionStore=%@",_sessionStore);
[self _resetCache];
timeInterval=[reqStartDate timeIntervalSinceNow];
// negate to make positive
timeInterval = timeInterval*-1.0;
[_statisticsStore _applicationDidHandleComponentActionRequestInTimeInterval:timeInterval];
NSDebugMLLog(@"requests",@"sessionStore=%@",_sessionStore);
};
if (!response)

View file

@ -60,7 +60,7 @@ static char rcsId[] = "$Id$";
-(GSWResponse*)lockedHandleRequest:(GSWRequest*)aRequest
{
//OK
GSWStatisticsStore* statisticsStore=nil;
//GSWStatisticsStore* statisticsStore=nil;
GSWApplication* application=[GSWApplication application];
GSWContext* aContext=nil;
GSWResponse* response=nil;
@ -92,9 +92,9 @@ static char rcsId[] = "$Id$";
if (!exceptionRaised)
{
NSDebugMLLog(@"requests",@"requestHandlerValues=%@",requestHandlerValues);
statisticsStore=[[GSWApplication application]statisticsStore];
NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
[statisticsStore _applicationWillHandleComponentActionRequest];
//statisticsStore=[[GSWApplication application]statisticsStore];
// NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
//[statisticsStore _applicationWillHandleComponentActionRequest];
aContext=[GSWContext contextWithRequest:aRequest];
NSDebugMLLog(@"aContext",@"aContext=%@",aContext);
senderID=[requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
@ -154,8 +154,8 @@ static char rcsId[] = "$Id$";
};
[application _setContext:nil];
statisticsStore=[[GSWApplication application] statisticsStore];
[statisticsStore _applicationDidHandleComponentActionRequest];
//statisticsStore=[[GSWApplication application] statisticsStore];
//[statisticsStore _applicationDidHandleComponentActionRequest];
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return response;

View file

@ -287,7 +287,7 @@ static char rcsId[] = "$Id$";
GSWApplication* application=nil;
GSWStatisticsStore* statisticsStore=nil;
LOGObjectFnStart();
statisticsStore=[[GSWApplication application]statisticsStore];
statisticsStore=[GSWApp statisticsStore];
[statisticsStore _applicationCreatedSession:self];
ASSIGNCOPY(_sessionID,aSessionID);
@ -343,6 +343,7 @@ static char rcsId[] = "$Id$";
//call GSWApp _discountTerminatedSession
//call GSWApp statisticsStore
//call statstore _sessionTerminating:self
[[GSWApp statisticsStore] _sessionTerminating:self];
LOGObjectFnStop();
};
// componentDefinition _notifyObserversForDyingComponent:Main component

View file

@ -97,6 +97,7 @@
-(void)_sessionTerminating:(id)session;
-(void)_applicationCreatedSession:(GSWSession*)session;
-(void)_applicationDidHandleComponentActionRequest;
-(void)_applicationDidHandleComponentActionRequestInTimeInterval:(double)timeInterval;
-(void)_applicationDidHandleDirectActionRequestWithActionNamed:(id)name;
-(double)_applicationDidHandleRequest;
-(void)_applicationWillHandleDirectActionRequest;

View file

@ -102,10 +102,81 @@ static char rcsId[] = "$Id$";
};
//--------------------------------------------------------------------
/*
should return this:
2002-10-26 13:50:19.825 foobarWO[3207] stats=<CFDictionary 0xf6fa0 [0x8016024c]>{count = 5, capacity = 6, pairs = (
0 : Pages = <CFDictionary 0xf98f0 [0x8016024c]>{count = 1, capacity = 3, pairs = (
1 : Main = <CFDictionary 0xfb040 [0x8016024c]>{count = 4, capacity = 6, pairs = (
1 : Min Resp. Time = 0.06496943533420562432
2 : Max Resp. Time = 0.4728142097592352768
3 : Avg Resp. Time = 0.2195588141679763968
7 : Served = 5
)}
)}
3 : StartedAt = 2002-10-26 13:49:05 +0200
5 : Transactions = <CFDictionary 0xf82a0 [0x8016024c]>{count = 11, capacity = 11, pairs = (
0 : Component Action Transactions = 6
2 : Transaction Rate = 0
4 : Direct Action Avg. Transaction Time = 0
5 : Transactions = 6
7 : Avg. Idle Time = 12.154283278932174848
9 : Moving Avg. Idle Time = 12.154283278932174848
10 : Direct Action Transactions = 0
11 : Component Action Avg. Transaction Time = 0.2195588141679763456
12 : Moving Avg. Transaction Time = 0.2195588141679763456
13 : Avg. Transaction Time = 0.2195588141679763456
15 : Sample Size For Moving Avg. = 100
)}
6 : Sessions = <CFDictionary 0xfd290 [0x8016024c]>{count = 11, capacity = 11, pairs = (
0 : Peak Active Sessions Date = 2002-10-26 13:50:17 +0200
1 : Current Active Sessions = 2
4 : Peak Active Sessions = 2
6 : Avg. Memory Per Session = <CFDictionary 0xf8b00 [0x8016024c]>{count = 2, capacity = 3, pairs = (
2 : Virtual = 1388544
3 : Resident Set Size = 264192
)}
9 : Moving Avg. Transactions Per Session = 0
10 : Sample Size For Moving Avg. = 10
11 : Moving Avg. Session Life = 0
12 : Session Rate = 0
13 : Avg. Transactions Per Session = 0
14 : Avg. Session Life = 0
15 : Total Sessions Created = 2
)}
7 : Memory = <CFDictionary 0xfafe0 [0x8016024c]>{count = 2, capacity = 3, pairs = (
2 : Virtual = 541458432
3 : Resident Set Size = 1622016
)}
)}
*/
-(id)statistics
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
NSMutableDictionary *statDict = [NSMutableDictionary dictionary];
NSMutableDictionary *sessionsDict = [NSMutableDictionary dictionary];
[statDict setObject:_startDate
forKey:@"StartedAt"];
// Sessions
[sessionsDict setObject:[NSString stringWithFormat:@"%d",_sessionsCount]
forKey:@"Current Active Sessions"];
[statDict setObject:sessionsDict
forKey:@"Sessions"];
// Pages
if (_pagesStatistics) {
[statDict setObject:_pagesStatistics
forKey:@"Pages"];
}
// LOGObjectFnNotImplemented(); //TODOFN
return statDict;
};
//--------------------------------------------------------------------
@ -244,7 +315,7 @@ static char rcsId[] = "$Id$";
}
else
AvgRespTimeValue=aTimeInterval;
Served++;
ServedValue++;
}
else
{
@ -366,9 +437,42 @@ static char rcsId[] = "$Id$";
{
timeInterval=[self _applicationDidHandleRequest];
NSDebugMLog(@"currentPage=%@",_currentPage);
if (_currentPage)//TODO no current page if no session (error page,...)
if (_currentPage) { //TODO no current page if no session (error page,...)
NSLog(@"GSWStatisticsStore timeInterval=%f",timeInterval);
[self _updatePagesStatisticsForPage:_currentPage
timeInterval:timeInterval];
}
}
NS_HANDLER
{
NSDebugMLog(@"EXCEPTION:%@ (%@) [%s %d]",
localException,[localException reason],
__FILE__,__LINE__);
//TODO
[self unlock];
[localException raise];
}
NS_ENDHANDLER;
[self unlock];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)_applicationDidHandleComponentActionRequestInTimeInterval:(double)timeInterval
{
//OK
// double timeInterval=0;
LOGObjectFnStart();
[self lock];
NS_DURING
{
// timeInterval=[self _applicationDidHandleRequest];
NSDebugMLog(@"currentPage=%@",_currentPage);
if (_currentPage) { //TODO no current page if no session (error page,...)
NSLog(@"GSWStatisticsStore timeInterval=%f",timeInterval);
[self _updatePagesStatisticsForPage:_currentPage
timeInterval:timeInterval];
}
}
NS_HANDLER
{