phonebookengines_old/contactsmodel/tsrc/T_PlPerformanceAPI.h
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     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:Contacts.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 // CPlPerformanceAPI - the class implementing the 
       
    70 // Contact Performance Tests. 
       
    71 class CPlPerformanceAPI : public CCntTest 
       
    72 	{
       
    73 public:
       
    74 	static CPlPerformanceAPI* NewLC (CCntTestImplementor& aCntTestImpl, const TDesC& aFilename);
       
    75 	~CPlPerformanceAPI();
       
    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 	void DeleteDefaultDatabaseTestL();
       
    82 	void ListDatabaseTestL();
       
    83 	
       
    84 private:	
       
    85 	void CreateContactsTestL(TInt aSize);
       
    86 	void UpdateContactsTestL(const TInt aStartPos, const TInt aEndPos);
       
    87 	void DeleteContactsTestL(const TInt aStartPos, const TInt aEndPos);
       
    88 	
       
    89 private: // methods
       
    90 	void ConstructL      (const TDesC& aFilename);
       
    91 	void CreateTemplateL ();
       
    92 	TInt AddToIdBuffer   (TContactItemId aID);
       
    93 	void CreateTestDataL ();
       
    94 	void ShuffleContactIdsL();
       
    95 private: // contsructors
       
    96 	inline CPlPerformanceAPI(CCntTestImplementor& aCntTestImpl);
       
    97 
       
    98 private: // member variables
       
    99 	CContactItemViewDef* 	iMatchAll;
       
   100 	CCntItemBuilder* 		iCntItemBldr;
       
   101 	CIdBuffer* 				iIdBuffer;
       
   102 	CCsvWriter*				iCsvWriter;
       
   103 	bool					iShuffle;
       
   104 	};
       
   105 
       
   106 
       
   107 
       
   108 class CCsvWriter : CBase
       
   109 	{
       
   110 public:
       
   111 	static CCsvWriter* NewLC(const TDesC& aFilename);
       
   112 	~CCsvWriter();
       
   113 	void WriteNextLineL(const TDesC8& aCsvLine);
       
   114 
       
   115 private:
       
   116 	void ConstructL();
       
   117 	CCsvWriter() {};
       
   118 	RFs iFs;
       
   119 	RFile iSrcFile;
       
   120 	};
       
   121 	
       
   122 
       
   123 class CIdBuffer
       
   124 	{
       
   125 public:
       
   126 	CIdBuffer();
       
   127 	void AddL(TInt aID);
       
   128 	void RandomShuffleL();
       
   129 	TInt Get(TInt& aIndex) const;
       
   130 	
       
   131 	TInt Count() const;
       
   132 	inline ~CIdBuffer(){delete iContactIds;};
       
   133 private:
       
   134 	CArrayFix<TInt>* iContactIds; // Note Upper limit of 640 on RArray. 
       
   135 	};
       
   136 
       
   137 
       
   138 // Inline methods
       
   139 inline CPlPerformanceAPI::CPlPerformanceAPI (CCntTestImplementor& aCntTestImpl):CCntTest(aCntTestImpl),iShuffle(true) {};
       
   140 
       
   141 
       
   142 
       
   143 #endif //__T_PL_PERFORMANCE_H__