|
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 // This class are the concrete implementation of the right hand side of the |
|
15 // the bridge pattern. |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __T_PL_PERFORMANCE_H__ |
|
20 #define __T_PL_PERFORMANCE_H__ |
|
21 |
|
22 #include "NbCntTestLib/NbCntTestLib.h" |
|
23 #include "T_CntTest.h" |
|
24 #include "t_utils2.h" |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 namespace nsPlPerformance |
|
30 { |
|
31 _LIT(KCreatePlPerform, "C:PlPerform.cdb"); |
|
32 #if defined(__WINS__) |
|
33 _LIT(KPersistCSV, "C:\\PlPersist.csv"); |
|
34 _LIT(KContactCSV, "C:\\PlContact.csv"); |
|
35 _LIT(KClSvrCSV, "C:\\PlClntSvr.csv"); |
|
36 #else |
|
37 _LIT(KPersistCSV, "C:\\PlPersist.csv"); |
|
38 _LIT(KContactCSV, "C:\\PlContact.csv"); |
|
39 _LIT(KClSvrCSV, "C:\\PlClntSvr.csv"); |
|
40 |
|
41 #endif |
|
42 _LIT8(KColumnHeader, "TestName,Num Contacts ,Time\r\n"); |
|
43 _LIT(KNumber, "123456789"); |
|
44 _LIT(KName, "NAME"); |
|
45 _LIT(KEmail, "name@email.com"); |
|
46 _LIT(KHomeAdd, "Home address"); |
|
47 |
|
48 const TInt KFirstEntry = 0; |
|
49 const TInt KSize1Sample = 4; |
|
50 const TInt KSize2Sample = 16; |
|
51 const TInt KSize3Sample = 64; |
|
52 /* const TInt KSize4Sample = 256; |
|
53 const TInt KSize5Sample = 1024; |
|
54 const TInt KSize6Sample = 4096; |
|
55 */ |
|
56 const TInt KSize4Sample = 64; |
|
57 const TInt KSize5Sample = 64; |
|
58 const TInt KSize6Sample = 64; |
|
59 |
|
60 const TInt KBatchSize = 64; |
|
61 |
|
62 TInt64 KSeed = 10; |
|
63 } |
|
64 |
|
65 |
|
66 class CIdBuffer; |
|
67 class CCsvWriter; |
|
68 |
|
69 // CPlPerformance - the class implementing the |
|
70 // Contact Performance Tests. |
|
71 class CPlPerformance : public CCntTest |
|
72 { |
|
73 public: |
|
74 static CPlPerformance* NewLC (CCntTestImplementor& aCntTestImpl, const TDesC& aFilename); |
|
75 ~CPlPerformance(); |
|
76 |
|
77 void CreateContactsBatchL(TInt aSize); |
|
78 void UpdateContactsBatchL(const TInt aStartPos, const TInt aEndPos); |
|
79 void DeleteContactsBatchL(const TInt aStartPos, const TInt aEndPos); |
|
80 void ReadContactsTestL (const TInt aStartPos, const TInt aEndPos); |
|
81 |
|
82 private: |
|
83 void CreateContactsTestL(TInt aSize); |
|
84 void UpdateContactsTestL(const TInt aStartPos, const TInt aEndPos); |
|
85 void DeleteContactsTestL(const TInt aStartPos, const TInt aEndPos); |
|
86 |
|
87 |
|
88 private: // methods |
|
89 void ConstructL (const TDesC& aFilename); |
|
90 void CreateTemplateL (); |
|
91 TInt AddToIdBuffer (TContactItemId aID); |
|
92 void CreateTestDataL (); |
|
93 void ShuffleContactIdsL(); |
|
94 private: // contsructors |
|
95 inline CPlPerformance(CCntTestImplementor& aCntTestImpl); |
|
96 |
|
97 private: // member variables |
|
98 CContactItemViewDef* iMatchAll; |
|
99 CCntItemBuilder* iCntItemBldr; |
|
100 CIdBuffer* iIdBuffer; |
|
101 CCsvWriter* iCsvWriter; |
|
102 bool iShuffle; |
|
103 }; |
|
104 |
|
105 |
|
106 |
|
107 class CCsvWriter : CBase |
|
108 { |
|
109 public: |
|
110 static CCsvWriter* NewLC(const TDesC& aFilename); |
|
111 ~CCsvWriter(); |
|
112 void WriteNextLineL(const TDesC8& aCsvLine); |
|
113 |
|
114 private: |
|
115 void ConstructL(); |
|
116 CCsvWriter() {}; |
|
117 RFs iFs; |
|
118 RFile iSrcFile; |
|
119 }; |
|
120 |
|
121 |
|
122 class CIdBuffer |
|
123 { |
|
124 public: |
|
125 CIdBuffer(); |
|
126 void AddL(TInt aID); |
|
127 void RandomShuffleL(); |
|
128 TInt Get(TInt& aIndex) const; |
|
129 |
|
130 TInt Count() const; |
|
131 inline ~CIdBuffer(){delete iContactIds;}; |
|
132 private: |
|
133 CArrayFix<TInt>* iContactIds; // Note Upper limit of 640 on RArray. |
|
134 }; |
|
135 |
|
136 |
|
137 // Inline methods |
|
138 inline CPlPerformance::CPlPerformance (CCntTestImplementor& aCntTestImpl):CCntTest(aCntTestImpl),iShuffle(true) {}; |
|
139 |
|
140 |
|
141 |
|
142 #endif //__T_PL_PERFORMANCE_H__ |