summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/t_plperformanceapi.h
blob: 85bc8b1b15097b9f391c8a263fef9fc5b38c3b9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
* This class are the concrete implementation of the right hand side of the
* the bridge pattern.
*
*/


#ifndef __T_PL_PERFORMANCE_H__
#define __T_PL_PERFORMANCE_H__

#include "nbcnttestlib/nbcnttestlib.h"
#include "t_cnttest.h"
#include "t_utils2.h"




namespace nsPlPerformance
{
	_LIT(KCreatePlPerform, "C:Contacts.cdb");
#if defined(__WINS__)
	_LIT(KPersistCSV, "C:\\PlPersist.csv");	
	_LIT(KContactCSV, "C:\\PlContact.csv");
	_LIT(KClSvrCSV,	  "C:\\PlClntSvr.csv");
#else
	_LIT(KPersistCSV, "C:\\PlPersist.csv");	
	_LIT(KContactCSV, "C:\\PlContact.csv");	
	_LIT(KClSvrCSV,	  "C:\\PlClntSvr.csv");
	
#endif
	_LIT8(KColumnHeader, "TestName,Num Contacts ,Time\r\n");
	_LIT(KNumber, "123456789");
	_LIT(KName, "NAME");
	_LIT(KEmail, "name@email.com");
	_LIT(KHomeAdd, "Home address");
	
	const TInt KFirstEntry   = 0;
	const TInt KSize1Sample  = 4;
	const TInt KSize2Sample  = 16;
	const TInt KSize3Sample  = 64;
/*	const TInt KSize4Sample  = 256;
	const TInt KSize5Sample  = 1024;
	const TInt KSize6Sample  = 4096;
*/
	const TInt KSize4Sample  = 64;
	const TInt KSize5Sample  = 64;
	const TInt KSize6Sample  = 64;

	const TInt KBatchSize	 = 64;
	
	TInt64 KSeed 		 	 = 10;
}


class CIdBuffer;
class CCsvWriter;

// CPlPerformanceAPI - the class implementing the 
// Contact Performance Tests. 
class CPlPerformanceAPI : public CCntTest 
	{
public:
	static CPlPerformanceAPI* NewLC (CCntTestImplementor& aCntTestImpl, const TDesC& aFilename);
	~CPlPerformanceAPI();

	void CreateContactsBatchL(TInt aSize);
	void UpdateContactsBatchL(const TInt aStartPos, const TInt aEndPos);
	void DeleteContactsBatchL(const TInt aStartPos, const TInt aEndPos);
	void ReadContactsTestL  (const TInt aStartPos, const TInt aEndPos);	
	void DeleteDefaultDatabaseTestL();
	void ListDatabaseTestL();
	
private:	
	void CreateContactsTestL(TInt aSize);
	void UpdateContactsTestL(const TInt aStartPos, const TInt aEndPos);
	void DeleteContactsTestL(const TInt aStartPos, const TInt aEndPos);
	
private: // methods
	void ConstructL      (const TDesC& aFilename);
	void CreateTemplateL ();
	TInt AddToIdBuffer   (TContactItemId aID);
	void CreateTestDataL ();
	void ShuffleContactIdsL();
private: // contsructors
	inline CPlPerformanceAPI(CCntTestImplementor& aCntTestImpl);

private: // member variables
	CContactItemViewDef* 	iMatchAll;
	CCntItemBuilder* 		iCntItemBldr;
	CIdBuffer* 				iIdBuffer;
	CCsvWriter*				iCsvWriter;
	bool					iShuffle;
	};



class CCsvWriter : CBase
	{
public:
	static CCsvWriter* NewLC(const TDesC& aFilename);
	~CCsvWriter();
	void WriteNextLineL(const TDesC8& aCsvLine);

private:
	void ConstructL();
	CCsvWriter() {};
	RFs iFs;
	RFile iSrcFile;
	};
	

class CIdBuffer
	{
public:
	CIdBuffer();
	void AddL(TInt aID);
	void RandomShuffleL();
	TInt Get(TInt& aIndex) const;
	
	TInt Count() const;
	inline ~CIdBuffer(){delete iContactIds;};
private:
	CArrayFix<TInt>* iContactIds; // Note Upper limit of 640 on RArray. 
	};


// Inline methods
inline CPlPerformanceAPI::CPlPerformanceAPI (CCntTestImplementor& aCntTestImpl):CCntTest(aCntTestImpl),iShuffle(true) {};



#endif //__T_PL_PERFORMANCE_H__