author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 21 Jun 2010 17:12:14 +0300 | |
branch | RCL_3 |
changeset 39 | 2bb754abd467 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2002-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 the License "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 <e32test.h> |
|
17 |
#include <e32property.h> |
|
18 |
||
19 |
#include "bm_suite.h" |
|
20 |
||
21 |
static const TInt32 KUidPropBenchmarkCategoryValue = 0x101f75b7; |
|
22 |
static const TUid KPropBenchmarkCategory = { KUidPropBenchmarkCategoryValue }; |
|
23 |
static _LIT_SECURITY_POLICY_PASS(KPassPolicy); |
|
24 |
||
25 |
typedef void (*MeasurementFunc)(TBMResult*, TBMUInt64 aIter, struct Measurement*); |
|
26 |
enum TSetGetType |
|
27 |
{ |
|
28 |
EOneArg, |
|
29 |
EThreeArgsInt, |
|
30 |
EThreeArgsBuf8, |
|
31 |
EThreeArgsBuf16 |
|
32 |
}; |
|
33 |
||
34 |
struct Measurement |
|
35 |
{ |
|
36 |
MeasurementFunc iFunc; |
|
37 |
TPtrC iName; |
|
38 |
TBool iRemote; |
|
39 |
RProperty::TType iType; |
|
40 |
TInt iSize; |
|
41 |
TSetGetType iSetGetType; |
|
42 |
||
43 |
Measurement(MeasurementFunc aFunc, const TDesC& aName, |
|
44 |
RProperty::TType aType, TInt aSize, TBool aRemote = EFalse, |
|
45 |
TSetGetType aSetGetType = EOneArg) : |
|
46 |
iFunc(aFunc), iName(aName), iRemote(aRemote), iType(aType), iSize(aSize), |
|
47 |
iSetGetType(aSetGetType) {} |
|
48 |
}; |
|
49 |
||
50 |
class Property : public BMProgram |
|
51 |
{ |
|
52 |
public : |
|
53 |
Property() : BMProgram(_L("Properties")) |
|
54 |
{} |
|
55 |
virtual TBMResult* Run(TBMUInt64 aIter, TInt* aCount); |
|
56 |
||
57 |
||
58 |
static TBMResult iResults[]; |
|
59 |
static Measurement iMeasurements[]; |
|
60 |
||
61 |
static void NotificationLatencyParent(TBMResult* aResult, TBMUInt64 aIter, Measurement*); |
|
62 |
static TInt NotificationLatencyChild(TAny*); |
|
63 |
||
64 |
static void SetOverhead(TBMResult* aResult, TBMUInt64 aIter, struct Measurement* aM); |
|
65 |
static void GetOverhead(TBMResult* aResult, TBMUInt64 aIter, struct Measurement* aM); |
|
66 |
||
67 |
||
68 |
private: |
|
69 |
static TBuf8<RProperty::KMaxPropertySize> iInBuf; |
|
70 |
static TBuf8<RProperty::KMaxPropertySize> iOutBuf; |
|
71 |
static TBuf16<RProperty::KMaxPropertySize> iInBuf16; |
|
72 |
static TBuf16<RProperty::KMaxPropertySize> iOutBuf16; |
|
73 |
}; |
|
74 |
||
75 |
Measurement Property::iMeasurements[] = |
|
76 |
{ |
|
77 |
Measurement(&Property::NotificationLatencyParent, _L("Local Int Notification Latency "), |
|
78 |
RProperty::EInt, 0, EFalse), |
|
79 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Int Notification Latency"), |
|
80 |
RProperty::EInt, 0,ETrue), |
|
81 |
Measurement(&Property::NotificationLatencyParent, _L("Local Byte(1) Notification Latency"), |
|
82 |
RProperty::EByteArray, 1, EFalse), |
|
83 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Byte(1) Notification Latency"), |
|
84 |
RProperty::EByteArray, 1, ETrue), |
|
85 |
Measurement(&Property::NotificationLatencyParent, _L("Local Byte(8) Notification Latency"), |
|
86 |
RProperty::EByteArray, 8, EFalse), |
|
87 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Byte(8) Notification Latency"), |
|
88 |
RProperty::EByteArray, 8,ETrue), |
|
89 |
Measurement(&Property::NotificationLatencyParent, _L("Local Byte(512) Notification Latency"), |
|
90 |
RProperty::EByteArray, 512, EFalse), |
|
91 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Byte(512) Notification Latency"), |
|
92 |
RProperty::EByteArray, 512,ETrue), |
|
93 |
||
94 |
Measurement(&Property::NotificationLatencyParent, _L("Local Int Notification Latency ThreeArgsInt"), |
|
95 |
RProperty::EInt, 0, EFalse, EThreeArgsInt), |
|
96 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Int Notification Latency ThreeArgsInt"), |
|
97 |
RProperty::EInt, 0,ETrue, EThreeArgsInt), |
|
98 |
Measurement(&Property::NotificationLatencyParent, _L("Local Byte(1) Notification Latency ThreeArgsBuf8"), |
|
99 |
RProperty::EByteArray, 1, EFalse, EThreeArgsBuf8), |
|
100 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Byte(1) Notification Latency ThreeArgsBuf8"), |
|
101 |
RProperty::EByteArray, 1, ETrue, EThreeArgsBuf8), |
|
102 |
Measurement(&Property::NotificationLatencyParent, _L("Local TUint16(1) Notification Latency ThreeArgsBuf16"), |
|
103 |
RProperty::EByteArray, 1, EFalse, EThreeArgsBuf16), |
|
104 |
Measurement(&Property::NotificationLatencyParent, _L("Remote TUint16(1) Notification Latency ThreeArgsBuf16"), |
|
105 |
RProperty::EByteArray, 1, ETrue, EThreeArgsBuf16), |
|
106 |
Measurement(&Property::NotificationLatencyParent, _L("Local Byte(8) Notification Latency ThreeArgsBuf8"), |
|
107 |
RProperty::EByteArray, 8, EFalse, EThreeArgsBuf8), |
|
108 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Byte(8) Notification Latency ThreeArgsBuf8"), |
|
109 |
RProperty::EByteArray, 8,ETrue, EThreeArgsBuf8), |
|
110 |
Measurement(&Property::NotificationLatencyParent, _L("Local TUint16(8) Notification Latency ThreeArgsBuf16"), |
|
111 |
RProperty::EByteArray, 8, EFalse, EThreeArgsBuf16), |
|
112 |
Measurement(&Property::NotificationLatencyParent, _L("Remote TUint16(8) Notification Latency ThreeArgsBuf16"), |
|
113 |
RProperty::EByteArray, 8,ETrue, EThreeArgsBuf16), |
|
114 |
Measurement(&Property::NotificationLatencyParent, _L("Local Byte(512) Notification Latency ThreeArgsBuf8"), |
|
115 |
RProperty::EByteArray, 512, EFalse, EThreeArgsBuf8), |
|
116 |
Measurement(&Property::NotificationLatencyParent, _L("Remote Byte(512) Notification Latency ThreeArgsBuf8"), |
|
117 |
RProperty::EByteArray, 512,ETrue, EThreeArgsBuf8), |
|
118 |
Measurement(&Property::NotificationLatencyParent, _L("Local TUint16(512) Notification Latency ThreeArgsBuf16"), |
|
119 |
RProperty::ELargeByteArray, 512, EFalse, EThreeArgsBuf16), |
|
120 |
Measurement(&Property::NotificationLatencyParent, _L("Remote TUint16(512) Notification Latency ThreeArgsBuf16"), |
|
121 |
RProperty::ELargeByteArray, 512,ETrue, EThreeArgsBuf16), |
|
122 |
||
123 |
||
124 |
||
125 |
Measurement(&Property::SetOverhead, _L("Int Set Overhead"), |
|
126 |
RProperty::EInt, 0), |
|
127 |
Measurement(&Property::SetOverhead, _L("Byte(1) Set Overhead"), |
|
128 |
RProperty::EByteArray, 1), |
|
129 |
Measurement(&Property::SetOverhead, _L("Byte(8) Set Overhead"), |
|
130 |
RProperty::EByteArray, 8), |
|
131 |
Measurement(&Property::SetOverhead, _L("Byte(512) Set Overhead"), |
|
132 |
RProperty::EByteArray, 512), |
|
133 |
||
134 |
Measurement(&Property::SetOverhead, _L("Int Set Overhead ThreeArgsInt"), |
|
135 |
RProperty::EInt, 0, EFalse, EThreeArgsInt), |
|
136 |
Measurement(&Property::SetOverhead, _L("Byte(1) Set Overhead ThreeArgsBuf8"), |
|
137 |
RProperty::EByteArray, 1, EFalse, EThreeArgsBuf8), |
|
138 |
Measurement(&Property::SetOverhead, _L("TUint16(1) Set Overhead ThreeArgsBuf16"), |
|
139 |
RProperty::EByteArray, 1, EFalse, EThreeArgsBuf16), |
|
140 |
Measurement(&Property::SetOverhead, _L("Byte(8) Set Overhead ThreeArgsBuf8"), |
|
141 |
RProperty::EByteArray, 8, EFalse, EThreeArgsBuf8), |
|
142 |
Measurement(&Property::SetOverhead, _L("TUint16(8) Set Overhead ThreeArgsBuf16"), |
|
143 |
RProperty::EByteArray, 8, EFalse, EThreeArgsBuf16), |
|
144 |
Measurement(&Property::SetOverhead, _L("Byte(512) Set Overhead ThreeArgsBuf8"), |
|
145 |
RProperty::EByteArray, 512, EFalse, EThreeArgsBuf8), |
|
146 |
Measurement(&Property::SetOverhead, _L("TUint16(512) Set Overhead ThreeArgsBuf16"), |
|
147 |
RProperty::ELargeByteArray, 512, EFalse, EThreeArgsBuf16), |
|
148 |
||
149 |
||
150 |
||
151 |
Measurement(&Property::GetOverhead, _L("Int Get Overhead"), |
|
152 |
RProperty::EInt, 0), |
|
153 |
Measurement(&Property::GetOverhead, _L("Byte(1) Get Overhead"), |
|
154 |
RProperty::EByteArray, 1), |
|
155 |
Measurement(&Property::GetOverhead, _L("Byte(8) Get Overhead"), |
|
156 |
RProperty::EByteArray, 8), |
|
157 |
Measurement(&Property::GetOverhead, _L("Byte(512) Get Overhead"), |
|
158 |
RProperty::EByteArray, 512), |
|
159 |
||
160 |
Measurement(&Property::GetOverhead, _L("Int Get Overhead ThreeArgsInt"), |
|
161 |
RProperty::EInt, 0, EFalse, EThreeArgsInt), |
|
162 |
Measurement(&Property::GetOverhead, _L("Byte(1) Get Overhead ThreeArgsBuf8"), |
|
163 |
RProperty::EByteArray, 1, EFalse, EThreeArgsBuf8), |
|
164 |
Measurement(&Property::GetOverhead, _L("TUint16(1) Get Overhead ThreeArgsBuf16"), |
|
165 |
RProperty::EByteArray, 1, EFalse, EThreeArgsBuf16), |
|
166 |
Measurement(&Property::GetOverhead, _L("Byte(8) Get Overhead ThreeArgsBuf8"), |
|
167 |
RProperty::EByteArray, 8, EFalse, EThreeArgsBuf8), |
|
168 |
Measurement(&Property::GetOverhead, _L("TUint16(8) Get Overhead ThreeArgsBuf16"), |
|
169 |
RProperty::EByteArray, 8, EFalse, EThreeArgsBuf16), |
|
170 |
Measurement(&Property::GetOverhead, _L("Byte(512) Get Overhead ThreeArgsBuf8"), |
|
171 |
RProperty::EByteArray, 512, EFalse, EThreeArgsBuf8), |
|
172 |
Measurement(&Property::GetOverhead, _L("TUint16(512) Get Overhead ThreeArgsBuf16"), |
|
173 |
RProperty::ELargeByteArray, 512, EFalse, EThreeArgsBuf16), |
|
174 |
||
175 |
}; |
|
176 |
TBMResult Property::iResults[sizeof(Property::iMeasurements)/sizeof(Property::iMeasurements[0])]; |
|
177 |
||
178 |
TBuf8<RProperty::KMaxPropertySize> Property::iInBuf(RProperty::KMaxPropertySize); |
|
179 |
TBuf8<RProperty::KMaxPropertySize> Property::iOutBuf(RProperty::KMaxPropertySize); |
|
180 |
TBuf16<RProperty::KMaxPropertySize> Property::iInBuf16(RProperty::KMaxPropertySize); |
|
181 |
TBuf16<RProperty::KMaxPropertySize> Property::iOutBuf16(RProperty::KMaxPropertySize); |
|
182 |
||
183 |
||
184 |
static Property property; |
|
185 |
||
186 |
class NotificationLatencyArgs : public TBMSpawnArgs |
|
187 |
{ |
|
188 |
public: |
|
189 |
||
190 |
TBMUInt64 iIterationCount; |
|
191 |
RProperty::TType iType; |
|
192 |
TInt iSize; |
|
193 |
TSetGetType iSetGetType; |
|
194 |
||
195 |
NotificationLatencyArgs(RProperty::TType aType, TInt aSize, TInt aRemote, TBMUInt64 aIter, |
|
196 |
TSetGetType aSetGetType); |
|
197 |
}; |
|
198 |
||
199 |
NotificationLatencyArgs::NotificationLatencyArgs(RProperty::TType aType, TInt aSize, TInt aRemote, |
|
200 |
TBMUInt64 aIter, TSetGetType aSetGetType) : |
|
201 |
TBMSpawnArgs(Property::NotificationLatencyChild, KBMPriorityLow, aRemote, sizeof(*this)), |
|
202 |
iIterationCount(aIter), iType(aType), iSize(aSize), iSetGetType(aSetGetType) |
|
203 |
{ |
|
204 |
} |
|
205 |
||
206 |
void Property::NotificationLatencyParent(TBMResult* aResult, TBMUInt64 aIter, struct Measurement* aM) |
|
207 |
{ |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
TRequestStatus st1, st2; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
|
0 | 210 |
RProperty time; |
211 |
TInt r = time.Define(KPropBenchmarkCategory, 0, RProperty::EByteArray, KPassPolicy, KPassPolicy); |
|
212 |
BM_ERROR(r, r == KErrNone); |
|
213 |
r = time.Attach(KPropBenchmarkCategory, 0); |
|
214 |
BM_ERROR(r, r == KErrNone); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
time.Subscribe(st2); |
0 | 216 |
|
217 |
RProperty prop; |
|
218 |
r = prop.Define(KPropBenchmarkCategory, 1, aM->iType, KPassPolicy, KPassPolicy); |
|
219 |
BM_ERROR(r, r == KErrNone); |
|
220 |
r = prop.Attach(KPropBenchmarkCategory, 1); |
|
221 |
BM_ERROR(r, r == KErrNone); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
prop.Subscribe(st1); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
RSemaphore sync; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
r = sync.CreateGlobal(_L("sync"), 0); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
226 |
BM_ERROR(r, r == KErrNone); |
0 | 227 |
|
228 |
NotificationLatencyArgs sl(aM->iType, aM->iSize, aM->iRemote, aIter, aM->iSetGetType); |
|
229 |
MBMChild* child = property.SpawnChild(&sl); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
|
0 | 231 |
for (TBMUInt64 i = 0; i < aIter; ++i) |
232 |
{ |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
sync.Signal(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
234 |
User::WaitForRequest(st1); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
BM_ERROR(st1.Int(), st1.Int() == KErrNone); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
prop.Subscribe(st1); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
|
0 | 238 |
switch(aM->iSetGetType) |
239 |
{ |
|
240 |
case EOneArg: |
|
241 |
if (aM->iType == RProperty::EInt) |
|
242 |
{ |
|
243 |
TInt value; |
|
244 |
r = prop.Get(value); |
|
245 |
BM_ERROR(r, r == KErrNone); |
|
246 |
} |
|
247 |
else |
|
248 |
{ |
|
249 |
r = prop.Get(iInBuf); |
|
250 |
BM_ERROR(r, r == KErrNone); |
|
251 |
} |
|
252 |
break; |
|
253 |
case EThreeArgsInt: |
|
254 |
{ |
|
255 |
TInt value; |
|
256 |
r = prop.Get(KPropBenchmarkCategory, 1, value); |
|
257 |
BM_ERROR(r, r == KErrNone); |
|
258 |
} |
|
259 |
break; |
|
260 |
case EThreeArgsBuf8: |
|
261 |
r = prop.Get(KPropBenchmarkCategory, 1, iInBuf); |
|
262 |
BM_ERROR(r, r == KErrNone); |
|
263 |
break; |
|
264 |
case EThreeArgsBuf16: |
|
265 |
r = prop.Get(KPropBenchmarkCategory, 1, iInBuf16); |
|
266 |
BM_ERROR(r, r == KErrNone); |
|
267 |
break; |
|
268 |
} |
|
269 |
||
270 |
TBMTicks now; |
|
271 |
::bmTimer.Stamp(&now); |
|
272 |
||
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
273 |
User::WaitForRequest(st2); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
BM_ERROR(st2.Int(), st2.Int() == KErrNone); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
275 |
time.Subscribe(st2); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
276 |
|
0 | 277 |
// get the time just before Set() |
278 |
TBMTicks propSetTime; |
|
279 |
TPtr8 ptr((TUint8*) &propSetTime, sizeof(propSetTime), sizeof(propSetTime)); |
|
280 |
r = time.Get(KPropBenchmarkCategory, 0, ptr); |
|
281 |
BM_ERROR(r, r == KErrNone); |
|
282 |
||
283 |
aResult->Cumulate(TBMTicksDelta(propSetTime, now)); |
|
284 |
} |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
285 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
286 |
prop.Cancel(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
User::WaitForRequest(st1); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
BM_ERROR(st1.Int(), st1.Int() == KErrCancel); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
time.Cancel(); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
User::WaitForRequest(st2); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
BM_ERROR(st2.Int(), st2.Int() == KErrCancel); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
292 |
|
0 | 293 |
prop.Close(); |
294 |
time.Close(); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
sync.Close(); |
0 | 296 |
child->WaitChildExit(); |
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
|
0 | 298 |
r = prop.Delete(KPropBenchmarkCategory, 1); |
299 |
BM_ERROR(r, r == KErrNone); |
|
300 |
r = time.Delete(KPropBenchmarkCategory, 0); |
|
301 |
BM_ERROR(r, r == KErrNone); |
|
302 |
} |
|
303 |
||
304 |
TInt Property::NotificationLatencyChild(TAny* cookie) |
|
305 |
{ |
|
306 |
NotificationLatencyArgs* sl = (NotificationLatencyArgs*) cookie; |
|
307 |
TInt prio = BMProgram::SetAbsPriority(RThread(), sl->iChildOrigPriority); |
|
308 |
||
309 |
for (TInt j = 0; j < RProperty::KMaxPropertySize; ++j) |
|
310 |
{ |
|
311 |
iOutBuf[j] = (TUint8)(j + 1); |
|
312 |
} |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
|
0 | 314 |
RProperty time; |
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
315 |
TInt r = time.Attach(KPropBenchmarkCategory, 0); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
BM_ERROR(r, r == KErrNone); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
317 |
|
0 | 318 |
RProperty prop; |
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
r = prop.Attach(KPropBenchmarkCategory, 1); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
BM_ERROR(r, r == KErrNone); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
RSemaphore sync; |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
r = sync.OpenGlobal(_L("sync")); |
0 | 324 |
BM_ERROR(r, r == KErrNone); |
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
|
0 | 326 |
for (TBMUInt64 i = 0; i < sl->iIterationCount; ++i) |
327 |
{ |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
sync.Wait(); |
0 | 329 |
TBMTicks propSetTime; |
330 |
::bmTimer.Stamp(&propSetTime); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
331 |
|
0 | 332 |
switch(sl->iSetGetType) |
333 |
{ |
|
334 |
case EOneArg: |
|
335 |
if (sl->iType == RProperty::EInt) |
|
336 |
{ |
|
337 |
TInt value = 0xdeadbeef; |
|
338 |
r = prop.Set(value); |
|
339 |
BM_ERROR(r, r == KErrNone); |
|
340 |
} |
|
341 |
else |
|
342 |
{ |
|
343 |
TPtrC8 ptr(iOutBuf.Ptr(), sl->iSize); |
|
344 |
r = prop.Set(ptr); |
|
345 |
BM_ERROR(r, r == KErrNone); |
|
346 |
} |
|
347 |
break; |
|
348 |
case EThreeArgsInt: |
|
349 |
{ |
|
350 |
TInt value = 0xdeadbeef; |
|
351 |
r = prop.Set(KPropBenchmarkCategory, 1, value); |
|
352 |
BM_ERROR(r, r == KErrNone); |
|
353 |
} |
|
354 |
break; |
|
355 |
case EThreeArgsBuf8: |
|
356 |
{ |
|
357 |
TPtrC8 ptr(iOutBuf.Ptr(), sl->iSize); |
|
358 |
r = prop.Set(KPropBenchmarkCategory, 1, ptr); |
|
359 |
BM_ERROR(r, r == KErrNone); |
|
360 |
} |
|
361 |
break; |
|
362 |
case EThreeArgsBuf16: |
|
363 |
{ |
|
364 |
TPtrC16 ptr(iOutBuf16.Ptr(), sl->iSize); |
|
365 |
r = prop.Set(KPropBenchmarkCategory, 1, ptr); |
|
366 |
BM_ERROR(r, r == KErrNone); |
|
367 |
} |
|
368 |
break; |
|
369 |
} |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
370 |
|
0 | 371 |
// publish the time just before Set() |
372 |
TPtr8 ptr((TUint8*) &propSetTime, sizeof(propSetTime), sizeof(propSetTime)); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
r = time.Set(ptr); |
0 | 374 |
BM_ERROR(r, r == KErrNone); |
375 |
} |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
|
0 | 377 |
prop.Close(); |
378 |
time.Close(); |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
379 |
sync.Close(); |
0 | 380 |
|
381 |
BMProgram::SetAbsPriority(RThread(), prio); |
|
382 |
return KErrNone; |
|
383 |
} |
|
384 |
||
385 |
||
386 |
void Property::SetOverhead(TBMResult* aResult, TBMUInt64 aIter, struct Measurement* aM) |
|
387 |
{ |
|
388 |
RProperty prop; |
|
389 |
TInt r = prop.Define(KPropBenchmarkCategory, 1, aM->iType, KPassPolicy, KPassPolicy); |
|
390 |
BM_ERROR(r, r == KErrNone); |
|
391 |
r = prop.Attach(KPropBenchmarkCategory, 1); |
|
392 |
BM_ERROR(r, r == KErrNone); |
|
393 |
||
394 |
if (aM->iType == RProperty::EByteArray) |
|
395 |
{ |
|
396 |
TPtrC8 ptr(iOutBuf.Ptr(), aM->iSize); |
|
397 |
r = prop.Set(ptr); |
|
398 |
BM_ERROR(r, r == KErrNone); |
|
399 |
} |
|
400 |
||
401 |
TBMTimeInterval ti; |
|
402 |
ti.Begin(); |
|
403 |
for (TBMUInt64 i = 0; i < aIter; ++i) |
|
404 |
{ |
|
405 |
switch(aM->iSetGetType) |
|
406 |
{ |
|
407 |
case EOneArg: |
|
408 |
if (aM->iType == RProperty::EInt) |
|
409 |
{ |
|
410 |
TInt value = 1; |
|
411 |
r = prop.Set(value); |
|
412 |
BM_ERROR(r, r == KErrNone); |
|
413 |
} |
|
414 |
else |
|
415 |
{ |
|
416 |
TPtrC8 ptr(iOutBuf.Ptr(), aM->iSize); |
|
417 |
r = prop.Set(ptr); |
|
418 |
BM_ERROR(r, r == KErrNone); |
|
419 |
} |
|
420 |
break; |
|
421 |
case EThreeArgsInt: |
|
422 |
{ |
|
423 |
TInt value = 1; |
|
424 |
r = prop.Set(KPropBenchmarkCategory, 1, value); |
|
425 |
BM_ERROR(r, r == KErrNone); |
|
426 |
} |
|
427 |
break; |
|
428 |
case EThreeArgsBuf8: |
|
429 |
{ |
|
430 |
TPtrC8 ptr(iOutBuf.Ptr(), aM->iSize); |
|
431 |
r = prop.Set(KPropBenchmarkCategory, 1, ptr); |
|
432 |
BM_ERROR(r, r == KErrNone); |
|
433 |
} |
|
434 |
break; |
|
435 |
case EThreeArgsBuf16: |
|
436 |
{ |
|
437 |
TPtrC16 ptr(iOutBuf16.Ptr(), aM->iSize); |
|
438 |
r = prop.Set(KPropBenchmarkCategory, 1, ptr); |
|
439 |
BM_ERROR(r, r == KErrNone); |
|
440 |
} |
|
441 |
break; |
|
442 |
} |
|
443 |
} |
|
444 |
TBMTicks t = ti.End(); |
|
445 |
||
446 |
prop.Close(); |
|
447 |
r = prop.Delete(KPropBenchmarkCategory, 1); |
|
448 |
BM_ERROR(r, r == KErrNone); |
|
449 |
||
450 |
aResult->Cumulate(t, aIter); |
|
451 |
} |
|
452 |
||
453 |
void Property::GetOverhead(TBMResult* aResult, TBMUInt64 aIter, struct Measurement* aM) |
|
454 |
{ |
|
455 |
RProperty prop; |
|
456 |
TInt r = prop.Define(KPropBenchmarkCategory, 1, aM->iType, KPassPolicy, KPassPolicy); |
|
457 |
BM_ERROR(r, r == KErrNone); |
|
458 |
r = prop.Attach(KPropBenchmarkCategory, 1); |
|
459 |
BM_ERROR(r, r == KErrNone); |
|
460 |
||
461 |
if (aM->iType == RProperty::EByteArray) |
|
462 |
{ |
|
463 |
TPtrC8 ptr(iOutBuf.Ptr(), aM->iSize); |
|
464 |
r = prop.Set(ptr); |
|
465 |
BM_ERROR(r, r == KErrNone); |
|
466 |
} |
|
467 |
||
468 |
TBMTimeInterval ti; |
|
469 |
ti.Begin(); |
|
470 |
for (TBMUInt64 i = 0; i < aIter; ++i) |
|
471 |
{ |
|
472 |
switch(aM->iSetGetType) |
|
473 |
{ |
|
474 |
case EOneArg: |
|
475 |
if (aM->iType == RProperty::EInt) |
|
476 |
{ |
|
477 |
TInt value = 1; |
|
478 |
r = prop.Get(value); |
|
479 |
BM_ERROR(r, r == KErrNone); |
|
480 |
} |
|
481 |
else |
|
482 |
{ |
|
483 |
r = prop.Get(iInBuf); |
|
484 |
BM_ERROR(r, r == KErrNone); |
|
485 |
} |
|
486 |
break; |
|
487 |
case EThreeArgsInt: |
|
488 |
{ |
|
489 |
TInt value = 1; |
|
490 |
r = prop.Get(KPropBenchmarkCategory, 1, value); |
|
491 |
BM_ERROR(r, r == KErrNone); |
|
492 |
} |
|
493 |
break; |
|
494 |
case EThreeArgsBuf8: |
|
495 |
r = prop.Get(KPropBenchmarkCategory, 1, iInBuf); |
|
496 |
BM_ERROR(r, r == KErrNone); |
|
497 |
break; |
|
498 |
case EThreeArgsBuf16: |
|
499 |
r = prop.Get(KPropBenchmarkCategory, 1, iInBuf16); |
|
500 |
BM_ERROR(r, r == KErrNone); |
|
501 |
break; |
|
502 |
} |
|
503 |
} |
|
504 |
TBMTicks t = ti.End(); |
|
505 |
||
506 |
prop.Close(); |
|
507 |
r = prop.Delete(KPropBenchmarkCategory, 1); |
|
508 |
BM_ERROR(r, r == KErrNone); |
|
509 |
||
510 |
aResult->Cumulate(t, aIter); |
|
511 |
} |
|
512 |
||
513 |
||
514 |
||
515 |
TBMResult* Property::Run(TBMUInt64 aIter, TInt* aCount) |
|
516 |
{ |
|
517 |
TInt count = sizeof(iResults)/sizeof(iResults[0]); |
|
518 |
||
519 |
for (TInt i = 0; i < count; ++i) |
|
520 |
{ |
|
521 |
iResults[i].Reset(iMeasurements[i].iName); |
|
522 |
iMeasurements[i].iFunc(&iResults[i], aIter, &iMeasurements[i]); |
|
523 |
iResults[i].Update(); |
|
524 |
} |
|
525 |
||
526 |
*aCount = count; |
|
527 |
return iResults; |
|
528 |
} |
|
529 |
||
530 |
void AddProperty() |
|
531 |
{ |
|
532 |
BMProgram* next = bmSuite; |
|
533 |
bmSuite=(BMProgram*)&property; |
|
534 |
bmSuite->Next()=next; |
|
535 |
} |