|
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 // Persistence Layer Performance Test module |
|
15 // These tests compare the Contact Persistence Layer with the original |
|
16 // Contacts model. |
|
17 // This class is an implementation of the bridge pattern. It represents |
|
18 // the left hand side of the pattern or an abstraction class. The decoupled |
|
19 // implementation classes can be found in T_CntTestImplentor.h |
|
20 // |
|
21 // |
|
22 |
|
23 #include <e32test.h> |
|
24 #include <coreappstest/testserver.h> |
|
25 #include <cntitem.h> |
|
26 #include <cntfldst.h> |
|
27 |
|
28 _LIT(KTestName, "T_PlPerformance"); // Used by Testhelper - gives an warning under ARMv5 |
|
29 |
|
30 #include "T_PlPerformance.h" |
|
31 |
|
32 #include "testhelpers.h" |
|
33 #include "persistencelayer.h" |
|
34 |
|
35 #include "T_CntTestImplDefs.h" |
|
36 |
|
37 |
|
38 //#define RUN_CNT |
|
39 #define RUN_PL |
|
40 //#define RUN_CLIENT_SERVER |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 // Implementation of CPlPerformance member functions |
|
46 |
|
47 CPlPerformance* CPlPerformance::NewLC (CCntTestImplementor& aCntTestImpl, const TDesC& aFilename) |
|
48 { |
|
49 RDebug::Print(_L("CPlPerformance::NewLC")); |
|
50 |
|
51 CPlPerformance* self = new (ELeave) CPlPerformance(aCntTestImpl); |
|
52 CleanupStack::PushL(self); |
|
53 |
|
54 self->ConstructL(aFilename); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 void CPlPerformance::ConstructL(const TDesC& aFilename) |
|
60 { |
|
61 RDebug::Print(_L("CPlPerformance::ConstructL")); |
|
62 |
|
63 // 0 |
|
64 iCntTestImpl.CreateDatabaseL(nsPlPerformance::KCreatePlPerform, ETrue); |
|
65 // 1 |
|
66 iCntItemBldr = CCntItemBuilder::NewLC(iCntTestImpl.GetSysTemplate()); |
|
67 CleanupStack::Pop(iCntItemBldr); |
|
68 // 2 |
|
69 iIdBuffer = new (ELeave) CIdBuffer(); |
|
70 // 3 |
|
71 iMatchAll = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields, |
|
72 CContactItemViewDef::EIncludeHiddenFields); |
|
73 iMatchAll->AddL(KUidContactFieldMatchAll); |
|
74 CleanupStack::Pop(iMatchAll); |
|
75 // 4 |
|
76 iCsvWriter = CCsvWriter::NewLC(aFilename); |
|
77 CleanupStack::Pop(iCsvWriter); |
|
78 } |
|
79 |
|
80 |
|
81 |
|
82 CPlPerformance::~CPlPerformance() |
|
83 { |
|
84 RDebug::Print(_L("~CPlPerformance()")); |
|
85 |
|
86 // 4 |
|
87 delete iCsvWriter; |
|
88 // 3 |
|
89 delete iMatchAll; |
|
90 // 2 |
|
91 delete iIdBuffer; |
|
92 // 1 |
|
93 delete iCntItemBldr; |
|
94 // 0 |
|
95 iCntTestImpl.CloseDatabase(); |
|
96 } |
|
97 |
|
98 |
|
99 void CPlPerformance::CreateContactsBatchL(TInt aSize) |
|
100 { |
|
101 test.Next(_L(" ->... Create")); |
|
102 RDebug::Print(_L("CreateContactsTestL(TInt aSize)")); |
|
103 |
|
104 TTime startTime; |
|
105 startTime.UniversalTime(); |
|
106 |
|
107 for (int ii = 0; ii < aSize; ii+=nsPlPerformance::KBatchSize) |
|
108 { |
|
109 CreateContactsTestL(aSize<nsPlPerformance::KBatchSize ? |
|
110 aSize:nsPlPerformance::KBatchSize); |
|
111 if (ii >= nsPlPerformance::KBatchSize - 1) |
|
112 { |
|
113 iCntTestImpl.CompactL(); |
|
114 } |
|
115 } |
|
116 |
|
117 TTime finishTime; |
|
118 finishTime.UniversalTime(); |
|
119 // Temporary required for ARMv5, adress of Int64() is taken in |
|
120 // parameter to Format method otherwise. |
|
121 TReal lapsed = (TReal) finishTime.MicroSecondsFrom(startTime).Int64(); |
|
122 |
|
123 TBuf8<64> row; |
|
124 // _LIT8 gives an error - illegal implicit conversion from long |
|
125 row.Format(_L8("Create,%d,%.4f\r\n"), aSize, lapsed/1000000); |
|
126 iCsvWriter->WriteNextLineL(row); |
|
127 |
|
128 /*TBool compressFlag = */iCntTestImpl.CompressRequired(); |
|
129 |
|
130 } |
|
131 |
|
132 |
|
133 void CPlPerformance::CreateContactsTestL(TInt aSize) |
|
134 { |
|
135 CContactItem* tempCntItem = NULL; |
|
136 // create a contact & add to the contact db. |
|
137 for (int ii = 0; ii < aSize; ++ii) |
|
138 { |
|
139 tempCntItem = iCntItemBldr->GetCntItemLC(); |
|
140 iIdBuffer->AddL(iCntTestImpl.CreateL(*tempCntItem)); |
|
141 CleanupStack::PopAndDestroy(tempCntItem); |
|
142 tempCntItem = NULL; |
|
143 } |
|
144 } |
|
145 |
|
146 void CPlPerformance::UpdateContactsBatchL(const TInt aStartPos, const TInt aEndPos) |
|
147 { |
|
148 test.Next(_L(" ->... Update")); |
|
149 RDebug::Print(_L("CPlPerformance::UpdateContactsTestL")); |
|
150 |
|
151 ShuffleContactIdsL(); |
|
152 |
|
153 TInt size = iIdBuffer->Count() < aEndPos ? iIdBuffer->Count() : aEndPos; |
|
154 |
|
155 TTime startTime; |
|
156 startTime.UniversalTime(); |
|
157 |
|
158 for (int ii = aStartPos; ii < aEndPos; ii+=nsPlPerformance::KBatchSize) |
|
159 { |
|
160 UpdateContactsTestL(ii, size < nsPlPerformance::KBatchSize + ii ? |
|
161 size : nsPlPerformance::KBatchSize + ii); |
|
162 if (ii >= nsPlPerformance::KBatchSize - 1) |
|
163 { |
|
164 iCntTestImpl.CompactL(); |
|
165 } |
|
166 } |
|
167 |
|
168 TTime finishTime; |
|
169 finishTime.UniversalTime(); |
|
170 TReal lapsed = (TReal) finishTime.MicroSecondsFrom(startTime).Int64(); |
|
171 |
|
172 TBuf8<84> row; |
|
173 // _LIT8 gives an error - illegal implicit conversion from long |
|
174 row.Format(_L8("Update,%d,%.4f\r\n"), size - aStartPos, lapsed/1000000); |
|
175 iCsvWriter->WriteNextLineL(row); |
|
176 |
|
177 } |
|
178 |
|
179 void CPlPerformance::UpdateContactsTestL(const TInt aStartPos, const TInt aEndPos) |
|
180 { |
|
181 CContactItem* tempCntItem = NULL; |
|
182 |
|
183 for (int ii = aStartPos; ii < aEndPos; ++ii)//size; ++ii) |
|
184 { |
|
185 // Modify the data in a contact from the db |
|
186 tempCntItem = iCntTestImpl.OpenLC(iIdBuffer->Get(ii), *iMatchAll); |
|
187 TCnt cnt(tempCntItem); |
|
188 cnt[KUidContactFieldGivenName] = nsPlPerformance::KName; |
|
189 cnt[KUidContactFieldPhoneNumber] & KWork & KVoice = nsPlPerformance::KNumber; |
|
190 cnt[KUidContactFieldPhoneNumber] & KWork & KVoice & KCell += nsPlPerformance::KNumber; |
|
191 cnt[KUidContactFieldEMail] & KWork = nsPlPerformance::KEmail; |
|
192 cnt[KUidContactFieldAddress] & KHome = nsPlPerformance::KHomeAdd; |
|
193 iCntTestImpl.UpdateL(*tempCntItem); |
|
194 CleanupStack::PopAndDestroy(tempCntItem); |
|
195 } |
|
196 } |
|
197 |
|
198 |
|
199 void CPlPerformance::ReadContactsTestL(const TInt aStartPos, const TInt aEndPos) |
|
200 { |
|
201 test.Next(_L(" ->... Read")); |
|
202 RDebug::Print(_L("ReadContactsTestL")); |
|
203 |
|
204 ShuffleContactIdsL(); |
|
205 |
|
206 TTime startTime; |
|
207 startTime.UniversalTime(); |
|
208 |
|
209 TInt size = iIdBuffer->Count() < aEndPos ? iIdBuffer->Count() : aEndPos; |
|
210 for (int ii = aStartPos; ii < size; ++ii) |
|
211 { |
|
212 CleanupStack::PopAndDestroy(iCntTestImpl.ReadLC(iIdBuffer->Get(ii), *iMatchAll)); |
|
213 } |
|
214 TTime finishTime; |
|
215 |
|
216 finishTime.UniversalTime(); |
|
217 TReal lapsed = (TReal) finishTime.MicroSecondsFrom(startTime).Int64(); |
|
218 |
|
219 TBuf8<64> row; |
|
220 // _LIT8 gives an error - illegal implicit conversion from long |
|
221 row.Format(_L8("Read,%d,%.4f\r\n"), size - aStartPos, lapsed/1000000); |
|
222 iCsvWriter->WriteNextLineL(row); |
|
223 } |
|
224 |
|
225 |
|
226 |
|
227 void CPlPerformance::DeleteContactsBatchL(const TInt aStartPos, const TInt aEndPos) |
|
228 { |
|
229 test.Next(_L(" ->.. Delete.")); |
|
230 RDebug::Print(_L("DeleteContactsTestL")); |
|
231 |
|
232 ShuffleContactIdsL(); |
|
233 |
|
234 TInt size = iIdBuffer->Count() < aEndPos ? iIdBuffer->Count() : aEndPos; |
|
235 TTime startTime; |
|
236 startTime.UniversalTime(); |
|
237 |
|
238 for (int ii = aStartPos; ii < aEndPos; ii+=nsPlPerformance::KBatchSize) |
|
239 { |
|
240 DeleteContactsTestL(ii, size < nsPlPerformance::KBatchSize + ii ? |
|
241 size : nsPlPerformance::KBatchSize + ii); |
|
242 if (ii >= nsPlPerformance::KBatchSize - 1) |
|
243 { |
|
244 iCntTestImpl.CompactL(); |
|
245 } |
|
246 } |
|
247 |
|
248 TTime finishTime; |
|
249 finishTime.UniversalTime(); |
|
250 TReal lapsed = (TReal) finishTime.MicroSecondsFrom(startTime).Int64(); |
|
251 |
|
252 TBuf8<64> row; |
|
253 // _LIT8 gives an error - illegal implicit conversion from long |
|
254 row.Format(_L8("Delete,%d,%.4f\r\n"), size - aStartPos, lapsed/1000000); |
|
255 iCsvWriter->WriteNextLineL(row); |
|
256 |
|
257 /*TBool compressFlag = */iCntTestImpl.CompressRequired(); |
|
258 } |
|
259 |
|
260 |
|
261 |
|
262 void CPlPerformance::DeleteContactsTestL(const TInt aStartPos, const TInt aEndPos) |
|
263 { |
|
264 for (int ii = aStartPos; ii < aEndPos; ++ii) |
|
265 { |
|
266 iCntTestImpl.DeleteL(iIdBuffer->Get(ii)); |
|
267 } |
|
268 } |
|
269 |
|
270 |
|
271 void CPlPerformance::ShuffleContactIdsL() |
|
272 { |
|
273 RDebug::Print(_L("ShuffleContactIdsL")); |
|
274 |
|
275 if (iShuffle) // only ever shuffle once |
|
276 { |
|
277 iIdBuffer->RandomShuffleL(); |
|
278 iShuffle = false; |
|
279 } |
|
280 } |
|
281 |
|
282 // End of CPlPerformance member variables |
|
283 |
|
284 |
|
285 // CIdBuffer Class |
|
286 CIdBuffer::CIdBuffer() |
|
287 { |
|
288 RDebug::Print(_L("CIdBuffer()")); |
|
289 |
|
290 iContactIds = new CArrayFixFlat<TInt>(nsPlPerformance::KSize1Sample |
|
291 + nsPlPerformance::KSize2Sample + nsPlPerformance::KSize3Sample |
|
292 + nsPlPerformance::KSize4Sample + nsPlPerformance::KSize5Sample |
|
293 + nsPlPerformance::KSize6Sample + 1); |
|
294 if (!iContactIds) |
|
295 { |
|
296 test(EFalse); |
|
297 } |
|
298 } |
|
299 |
|
300 void CIdBuffer::AddL(TInt aID) |
|
301 { |
|
302 test.Printf(_L("Add Contact ID:%d \n"),aID); |
|
303 iContactIds->InsertL(iContactIds->Count(), aID); |
|
304 } |
|
305 |
|
306 void CIdBuffer::RandomShuffleL() |
|
307 { |
|
308 RDebug::Print(_L("CIdBuffer::RandomShuffleL")); |
|
309 |
|
310 TInt upperBounds = iContactIds->Count(); |
|
311 TInt orgVal = 0; |
|
312 TInt newVal = 0; |
|
313 TInt ranPos = 0; |
|
314 |
|
315 for (TInt ii = 0; ii < upperBounds; ++ii) |
|
316 { |
|
317 ranPos = Math::Rand(nsPlPerformance::KSeed) % upperBounds; |
|
318 orgVal = iContactIds->At(ii); |
|
319 newVal = iContactIds->At(ranPos); |
|
320 iContactIds->Delete(ranPos); |
|
321 iContactIds->InsertL(ranPos, orgVal); |
|
322 iContactIds->Delete(ii); |
|
323 iContactIds->InsertL(ii, newVal); |
|
324 } |
|
325 } |
|
326 |
|
327 TInt CIdBuffer::Get(TInt& aIndex) const |
|
328 { |
|
329 test.Printf(_L("Get Contact ID @ index: %d \n"),aIndex); |
|
330 return iContactIds->At(aIndex); |
|
331 } |
|
332 |
|
333 TInt CIdBuffer::Count() const |
|
334 { |
|
335 RDebug::Print(_L("CIdBuffer::Count()")); |
|
336 |
|
337 return iContactIds->Count(); |
|
338 } |
|
339 // End of CIdBuffer class implementation |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 // CCsvWriter class |
|
347 CCsvWriter::~CCsvWriter() |
|
348 { |
|
349 RDebug::Print(_L("~CCsvWriter()")); |
|
350 |
|
351 iSrcFile.Close(); |
|
352 } |
|
353 |
|
354 CCsvWriter* CCsvWriter::NewLC(const TDesC& filename) |
|
355 { |
|
356 RDebug::Print(_L("CCsvWriter::NewLC")); |
|
357 |
|
358 CCsvWriter* self = new (ELeave) CCsvWriter(); |
|
359 CleanupStack::PushL (self); |
|
360 User::LeaveIfError (self->iFs.Connect()); |
|
361 |
|
362 TInt err = self->iSrcFile.Open (self->iFs, filename, EFileWrite); |
|
363 if (err == KErrNotFound) |
|
364 err = self->iSrcFile.Create(self->iFs, filename, EFileWrite); |
|
365 if (err < KErrNone) |
|
366 User::Leave(err); |
|
367 |
|
368 self->ConstructL(); |
|
369 return self; |
|
370 } |
|
371 |
|
372 void CCsvWriter::ConstructL() |
|
373 { |
|
374 RDebug::Print(_L("ConstructL()")); |
|
375 |
|
376 // Write the header line. |
|
377 WriteNextLineL(nsPlPerformance::KColumnHeader); |
|
378 } |
|
379 |
|
380 void CCsvWriter::WriteNextLineL(const TDesC8& aCsvLine) |
|
381 { |
|
382 RDebug::Print(_L("WriteNextLineL")); |
|
383 |
|
384 User::LeaveIfError(iSrcFile.Write(aCsvLine)); |
|
385 } |
|
386 |
|
387 // End of CCsvWriter class implementation |
|
388 |
|
389 // Temporary CompressRequired Test |
|
390 void DoPlCompressRequiredTestsL(CPlPerformance& aCntTests) |
|
391 { |
|
392 RDebug::Print(_L("DoPlCompressRequiredTestsL")); |
|
393 test.Next(_L(" -> Adding contacts...")); |
|
394 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize1Sample); |
|
395 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry, |
|
396 nsPlPerformance::KSize1Sample); |
|
397 |
|
398 |
|
399 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize2Sample); |
|
400 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry + |
|
401 nsPlPerformance::KSize1Sample, |
|
402 nsPlPerformance::KFirstEntry + |
|
403 nsPlPerformance::KSize1Sample + |
|
404 nsPlPerformance::KSize2Sample); |
|
405 |
|
406 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize3Sample); |
|
407 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry + |
|
408 nsPlPerformance::KSize1Sample + |
|
409 nsPlPerformance::KSize2Sample, |
|
410 nsPlPerformance::KFirstEntry + |
|
411 nsPlPerformance::KSize1Sample + |
|
412 nsPlPerformance::KSize2Sample+ |
|
413 nsPlPerformance::KSize3Sample); |
|
414 } |
|
415 |
|
416 |
|
417 void DoPlTestsL(CPlPerformance& aCntTests) |
|
418 { |
|
419 RDebug::Print(_L("DoPlTestsL")); |
|
420 |
|
421 test.Next(_L(" -> Adding contacts...")); |
|
422 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize1Sample); |
|
423 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize2Sample); |
|
424 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize3Sample); |
|
425 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize4Sample); |
|
426 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize5Sample); |
|
427 aCntTests.CreateContactsBatchL(nsPlPerformance::KSize6Sample); |
|
428 |
|
429 |
|
430 test.Next(_L(" -> Updating contacts...")); |
|
431 aCntTests.UpdateContactsBatchL(nsPlPerformance::KFirstEntry, |
|
432 nsPlPerformance::KSize1Sample); |
|
433 |
|
434 aCntTests.UpdateContactsBatchL(nsPlPerformance::KFirstEntry + |
|
435 nsPlPerformance::KSize1Sample, |
|
436 nsPlPerformance::KFirstEntry + |
|
437 nsPlPerformance::KSize1Sample + |
|
438 nsPlPerformance::KSize2Sample); |
|
439 |
|
440 aCntTests.UpdateContactsBatchL(nsPlPerformance::KFirstEntry + |
|
441 nsPlPerformance::KSize1Sample + |
|
442 nsPlPerformance::KSize2Sample, |
|
443 nsPlPerformance::KFirstEntry + |
|
444 nsPlPerformance::KSize1Sample + |
|
445 nsPlPerformance::KSize2Sample+ |
|
446 nsPlPerformance::KSize3Sample); |
|
447 |
|
448 aCntTests.UpdateContactsBatchL(nsPlPerformance::KFirstEntry + |
|
449 nsPlPerformance::KSize1Sample + |
|
450 nsPlPerformance::KSize2Sample + |
|
451 nsPlPerformance::KSize3Sample, |
|
452 nsPlPerformance::KFirstEntry + |
|
453 nsPlPerformance::KSize1Sample + |
|
454 nsPlPerformance::KSize2Sample + |
|
455 nsPlPerformance::KSize3Sample + |
|
456 nsPlPerformance::KSize4Sample); |
|
457 |
|
458 aCntTests.UpdateContactsBatchL(nsPlPerformance::KFirstEntry + |
|
459 nsPlPerformance::KSize1Sample + |
|
460 nsPlPerformance::KSize2Sample + |
|
461 nsPlPerformance::KSize3Sample + |
|
462 nsPlPerformance::KSize4Sample, |
|
463 nsPlPerformance::KFirstEntry + |
|
464 nsPlPerformance::KSize1Sample + |
|
465 nsPlPerformance::KSize2Sample + |
|
466 nsPlPerformance::KSize3Sample + |
|
467 nsPlPerformance::KSize4Sample + |
|
468 nsPlPerformance::KSize5Sample); |
|
469 |
|
470 aCntTests.UpdateContactsBatchL(nsPlPerformance::KFirstEntry + |
|
471 nsPlPerformance::KSize1Sample + |
|
472 nsPlPerformance::KSize2Sample + |
|
473 nsPlPerformance::KSize3Sample + |
|
474 nsPlPerformance::KSize4Sample + |
|
475 nsPlPerformance::KSize5Sample, |
|
476 nsPlPerformance::KFirstEntry + |
|
477 nsPlPerformance::KSize1Sample + |
|
478 nsPlPerformance::KSize2Sample + |
|
479 nsPlPerformance::KSize3Sample + |
|
480 nsPlPerformance::KSize4Sample + |
|
481 nsPlPerformance::KSize5Sample + |
|
482 nsPlPerformance::KSize6Sample); |
|
483 |
|
484 test.Next(_L(" -> Reading contacts...")); |
|
485 aCntTests.ReadContactsTestL(nsPlPerformance::KFirstEntry, |
|
486 nsPlPerformance::KSize1Sample); |
|
487 |
|
488 aCntTests.ReadContactsTestL(nsPlPerformance::KFirstEntry + |
|
489 nsPlPerformance::KSize1Sample, |
|
490 nsPlPerformance::KFirstEntry + |
|
491 nsPlPerformance::KSize1Sample + |
|
492 nsPlPerformance::KSize2Sample); |
|
493 |
|
494 aCntTests.ReadContactsTestL(nsPlPerformance::KFirstEntry + |
|
495 nsPlPerformance::KSize1Sample + |
|
496 nsPlPerformance::KSize2Sample, |
|
497 nsPlPerformance::KFirstEntry + |
|
498 nsPlPerformance::KSize1Sample + |
|
499 nsPlPerformance::KSize2Sample+ |
|
500 nsPlPerformance::KSize3Sample); |
|
501 |
|
502 aCntTests.ReadContactsTestL(nsPlPerformance::KFirstEntry + |
|
503 nsPlPerformance::KSize1Sample + |
|
504 nsPlPerformance::KSize2Sample + |
|
505 nsPlPerformance::KSize3Sample, |
|
506 nsPlPerformance::KFirstEntry + |
|
507 nsPlPerformance::KSize1Sample + |
|
508 nsPlPerformance::KSize2Sample + |
|
509 nsPlPerformance::KSize3Sample + |
|
510 nsPlPerformance::KSize4Sample); |
|
511 |
|
512 aCntTests.ReadContactsTestL(nsPlPerformance::KFirstEntry + |
|
513 nsPlPerformance::KSize1Sample + |
|
514 nsPlPerformance::KSize2Sample + |
|
515 nsPlPerformance::KSize3Sample + |
|
516 nsPlPerformance::KSize4Sample, |
|
517 nsPlPerformance::KFirstEntry + |
|
518 nsPlPerformance::KSize1Sample + |
|
519 nsPlPerformance::KSize2Sample + |
|
520 nsPlPerformance::KSize3Sample + |
|
521 nsPlPerformance::KSize4Sample + |
|
522 nsPlPerformance::KSize5Sample); |
|
523 |
|
524 aCntTests.ReadContactsTestL(nsPlPerformance::KFirstEntry + |
|
525 nsPlPerformance::KSize1Sample + |
|
526 nsPlPerformance::KSize2Sample + |
|
527 nsPlPerformance::KSize3Sample + |
|
528 nsPlPerformance::KSize4Sample + |
|
529 nsPlPerformance::KSize5Sample, |
|
530 nsPlPerformance::KFirstEntry + |
|
531 nsPlPerformance::KSize1Sample + |
|
532 nsPlPerformance::KSize2Sample + |
|
533 nsPlPerformance::KSize3Sample + |
|
534 nsPlPerformance::KSize4Sample + |
|
535 nsPlPerformance::KSize5Sample + |
|
536 nsPlPerformance::KSize6Sample); |
|
537 |
|
538 test.Next(_L(" -> Deleting contacts...")); |
|
539 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry, |
|
540 nsPlPerformance::KSize1Sample); |
|
541 |
|
542 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry + |
|
543 nsPlPerformance::KSize1Sample, |
|
544 nsPlPerformance::KFirstEntry + |
|
545 nsPlPerformance::KSize1Sample + |
|
546 nsPlPerformance::KSize2Sample); |
|
547 |
|
548 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry + |
|
549 nsPlPerformance::KSize1Sample + |
|
550 nsPlPerformance::KSize2Sample, |
|
551 nsPlPerformance::KFirstEntry + |
|
552 nsPlPerformance::KSize1Sample + |
|
553 nsPlPerformance::KSize2Sample+ |
|
554 nsPlPerformance::KSize3Sample); |
|
555 |
|
556 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry + |
|
557 nsPlPerformance::KSize1Sample + |
|
558 nsPlPerformance::KSize2Sample + |
|
559 nsPlPerformance::KSize3Sample, |
|
560 nsPlPerformance::KFirstEntry + |
|
561 nsPlPerformance::KSize1Sample + |
|
562 nsPlPerformance::KSize2Sample + |
|
563 nsPlPerformance::KSize3Sample + |
|
564 nsPlPerformance::KSize4Sample); |
|
565 |
|
566 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry + |
|
567 nsPlPerformance::KSize1Sample + |
|
568 nsPlPerformance::KSize2Sample + |
|
569 nsPlPerformance::KSize3Sample + |
|
570 nsPlPerformance::KSize4Sample, |
|
571 nsPlPerformance::KFirstEntry + |
|
572 nsPlPerformance::KSize1Sample + |
|
573 nsPlPerformance::KSize2Sample + |
|
574 nsPlPerformance::KSize3Sample + |
|
575 nsPlPerformance::KSize4Sample + |
|
576 nsPlPerformance::KSize5Sample); |
|
577 |
|
578 aCntTests.DeleteContactsBatchL(nsPlPerformance::KFirstEntry + |
|
579 nsPlPerformance::KSize1Sample + |
|
580 nsPlPerformance::KSize2Sample + |
|
581 nsPlPerformance::KSize3Sample + |
|
582 nsPlPerformance::KSize4Sample + |
|
583 nsPlPerformance::KSize5Sample, |
|
584 nsPlPerformance::KFirstEntry + |
|
585 nsPlPerformance::KSize1Sample + |
|
586 nsPlPerformance::KSize2Sample + |
|
587 nsPlPerformance::KSize3Sample + |
|
588 nsPlPerformance::KSize4Sample + |
|
589 nsPlPerformance::KSize5Sample + |
|
590 nsPlPerformance::KSize6Sample); |
|
591 } |
|
592 |
|
593 /** |
|
594 |
|
595 @SYMTestCaseID PIM-T-PIPERFORMANCE-0001 |
|
596 |
|
597 */ |
|
598 |
|
599 LOCAL_C void DoTestsL() |
|
600 { |
|
601 CleanupClosePushL(test); |
|
602 test.Start(_L ("@SYMTestCaseID:PIM-T-PIPERFORMANCE-0001 ----------- Performance tests ---------- ")); |
|
603 |
|
604 // Setup test |
|
605 CPlPerformance* performTest = NULL; |
|
606 |
|
607 // Run the old contact model test |
|
608 #ifdef RUN_CNT |
|
609 test.Start(_L(" ---- Contact Model Tests ---- ")); |
|
610 |
|
611 __UHEAP_MARK; |
|
612 |
|
613 CCntTestImpl* oldCntTestImpl = CCntTestImpl::NewLC(); |
|
614 performTest = CPlPerformance::NewLC(*oldCntTestImpl, |
|
615 nsPlPerformance::KContactCSV); |
|
616 |
|
617 DoPlTestsL(*performTest); |
|
618 |
|
619 CleanupStack::PopAndDestroy(performTest); |
|
620 performTest = NULL; |
|
621 CleanupStack::PopAndDestroy(oldCntTestImpl); |
|
622 oldCntTestImpl = NULL; |
|
623 |
|
624 __UHEAP_MARKEND; |
|
625 test.End(); |
|
626 |
|
627 #endif // RUN_CNT |
|
628 |
|
629 // Run the new persistence layer test |
|
630 #ifdef RUN_PL |
|
631 test.Start(_L(" ---- Persistence Layer Tests ---- ")); |
|
632 |
|
633 __UHEAP_MARK; |
|
634 |
|
635 CPlTestImpl* plCntTestImpl = CPlTestImpl::NewLC(); |
|
636 performTest = CPlPerformance::NewLC(*plCntTestImpl, |
|
637 nsPlPerformance::KPersistCSV); |
|
638 |
|
639 DoPlTestsL(*performTest); |
|
640 //DoPlCompressRequiredTestsL(*performTest); |
|
641 |
|
642 CleanupStack::PopAndDestroy(performTest); |
|
643 performTest = NULL; |
|
644 CleanupStack::PopAndDestroy(plCntTestImpl); |
|
645 plCntTestImpl = NULL; |
|
646 |
|
647 __UHEAP_MARKEND; |
|
648 test.End(); |
|
649 |
|
650 #endif // RUN_PL |
|
651 |
|
652 |
|
653 |
|
654 // Run the new client server test |
|
655 #ifdef RUN_CLIENT_SERVER |
|
656 test.Start(_L(" ---- Client Server Tests ---- ")); |
|
657 |
|
658 __UHEAP_MARK; |
|
659 |
|
660 CClientSvrImpl* clsvrTestImpl = CClientSvrImpl::NewLC(); |
|
661 performTest = CPlPerformance::NewLC(*clsvrTestImpl, |
|
662 nsPlPerformance::KClSvrCSV); |
|
663 |
|
664 DoPlTestsL(*performTest); |
|
665 |
|
666 CleanupStack::PopAndDestroy(performTest); |
|
667 performTest = NULL; |
|
668 CleanupStack::PopAndDestroy(clsvrTestImpl); |
|
669 clsvrTestImpl = NULL; |
|
670 |
|
671 __UHEAP_MARKEND; |
|
672 test.End(); |
|
673 |
|
674 #endif // RUN_CLIENT_SERVER |
|
675 |
|
676 |
|
677 test.End(); |
|
678 CleanupStack::PopAndDestroy(1); // test.Close |
|
679 } |
|
680 |
|
681 |
|
682 |
|
683 |
|
684 GLDEF_C TInt E32Main() |
|
685 { |
|
686 // Init |
|
687 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
688 if (!cleanupStack) |
|
689 return KErrNoMemory; |
|
690 |
|
691 CActiveScheduler* activeScheduler = new CActiveScheduler; |
|
692 if (!activeScheduler) |
|
693 return KErrNoMemory; |
|
694 CActiveScheduler::Install(activeScheduler); |
|
695 |
|
696 // Run the tests |
|
697 __UHEAP_MARK; |
|
698 TRAPD(err, DoTestsL()); |
|
699 __UHEAP_MARKEND; |
|
700 |
|
701 test(__NB_failures == 0); |
|
702 |
|
703 // Cleanup |
|
704 delete activeScheduler; |
|
705 delete cleanupStack; |
|
706 activeScheduler = NULL; |
|
707 cleanupStack = NULL; |
|
708 |
|
709 return err; |
|
710 } |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |