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