|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "srvPerf.h" |
|
17 |
|
18 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
19 |
|
20 #include "srvreqs.h" |
|
21 #include "srvsubsess.h" |
|
22 |
|
23 // SessionClose |
|
24 // Decrement reference count. If no more active sessions |
|
25 // then advance iLastCompleteAccess |
|
26 void TCentRepPerfTest::SessionClose() |
|
27 { |
|
28 iActiveSessionCount--; |
|
29 // There are clients who never close their sessions. Hence |
|
30 // cannot use iActiveSessionCount == 0 as indication to copy |
|
31 // iCount to iLastCompleteAccess. |
|
32 |
|
33 if (!IsFinished()) |
|
34 { |
|
35 iLastCompleteAccess = iCount; |
|
36 } |
|
37 } |
|
38 |
|
39 // Append |
|
40 // Add the integer if iEntries array is not full yet. |
|
41 TInt TCentRepPerfTest::Append(TUint32 aEntry) |
|
42 { |
|
43 if (iCount < KCentRepPerfTestArraySize) |
|
44 { |
|
45 iEntries[iCount++] = aEntry; |
|
46 return KErrNone; |
|
47 } |
|
48 return KErrOverflow; |
|
49 } |
|
50 |
|
51 // Function EncodeEventAndData |
|
52 // Put event Id in upper 8 bit and data in lower 24 bit. |
|
53 inline |
|
54 TUint32 EncodeEventAndData(TUint aEventId, TUint32 aData) |
|
55 { |
|
56 return ((aEventId & KEventIdMask) << KEventIdShiftBits) | |
|
57 (aData & KDataMask); |
|
58 } |
|
59 |
|
60 // Save initial values of timer |
|
61 void TCentRepPerfTest::DoEventStart(CServerSubSession* aSubSession, const TClientRequest& /*aMessage*/) |
|
62 { |
|
63 if(IsFinished()) |
|
64 { |
|
65 return; |
|
66 } |
|
67 |
|
68 //set the uid of the repository that this operation will be |
|
69 //performed on as the current repository |
|
70 if(aSubSession) //aSubSession would be NULL in the case of EInitialise and EClose operations |
|
71 { |
|
72 SetCurrentRepositoryUid(aSubSession->RepositoryUid().iUid); |
|
73 } |
|
74 |
|
75 iStartTick = User::FastCounter(); |
|
76 } |
|
77 |
|
78 // Save initial values of timer |
|
79 void TCentRepPerfTest::DoServerStart() |
|
80 { |
|
81 iStartTick = User::FastCounter(); |
|
82 } |
|
83 |
|
84 // store time of event, etc. in performance array |
|
85 void TCentRepPerfTest::DoServerEnd() |
|
86 { |
|
87 TUint32 endTick = User::FastCounter(); |
|
88 |
|
89 TServerRequest fn = EInitialiseServer; |
|
90 TUint32 entry = EncodeEventAndData(fn, endTick - iStartTick); |
|
91 Append(entry); |
|
92 } |
|
93 |
|
94 // store time of event, etc. in performance array |
|
95 void TCentRepPerfTest::DoEventEnd(CServerSubSession* /*aSubSession*/, const TClientRequest& aMessage) |
|
96 { |
|
97 TUint32 endTick = User::FastCounter(); |
|
98 |
|
99 if (IsFinished()) |
|
100 { |
|
101 return; |
|
102 } |
|
103 |
|
104 TServerRequest fn = static_cast<TServerRequest>(aMessage.Function()); |
|
105 // Performance data has 3 parts. First: time spent to |
|
106 // service the request. 2nd if event is open/close/evict |
|
107 // time of the event. 3rd, if open/close/evict repository UID |
|
108 |
|
109 // First part: event ID and CPU time spent servicing the request |
|
110 TUint32 entry = EncodeEventAndData(fn, endTick - iStartTick); |
|
111 Append(entry); |
|
112 |
|
113 if (fn == EInitialise) |
|
114 { |
|
115 SessionOpen(); |
|
116 |
|
117 //store the repository UID in the subsession so that we can refer to it later |
|
118 SetCurrentRepositoryUid(aMessage.Int0()); |
|
119 } |
|
120 |
|
121 //get the uid of the repository that this operation is being performed on |
|
122 TUint32 currentRepositoryUid = CurrentRepositoryUid(); |
|
123 |
|
124 TBool repOpenCloseEvict = fn == EInitialise || fn == EClose || fn == EEvict; |
|
125 |
|
126 // Third part: repository UID if event is open/close/evict. |
|
127 if (repOpenCloseEvict) |
|
128 { |
|
129 Append(iStartTick); |
|
130 Append(currentRepositoryUid); // Append will check if array IsFull. |
|
131 } |
|
132 |
|
133 // One last thing to do: check if all concurrent sessions close. |
|
134 if (fn == EClose) |
|
135 { |
|
136 SessionClose(); |
|
137 |
|
138 // This is a temporary solution to detect end-of-boot until SS code is |
|
139 // modified to return end-of-boot state and Centrep becomes SSA |
|
140 if (currentRepositoryUid == 0xCCCCCC00) |
|
141 { |
|
142 IncEndOfBoot(); |
|
143 } |
|
144 } |
|
145 } |
|
146 |
|
147 |
|
148 #endif //__CENTREP_SERVER_PERFTEST__ |
|
149 |