persistentstorage/centralrepository/test/testexecute/performance/src/TE_FindPerfTestStep.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 0 08ec8eefde2f
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
       
     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 //
       
    15 
       
    16 #include "TE_FindPerfTestStep.h"
       
    17 #include "TE_PerfTestUtilities.h"
       
    18 #include <centralrepository.h>
       
    19 #include "centralrepositoryinternal.h"
       
    20 #include <hal.h>
       
    21 #include <hal_data.h>
       
    22 
       
    23 using namespace NCentralRepositoryConstants;
       
    24 
       
    25 const TUid KUidFindPerfTestRepositorySmTxt = { 0x00000105 };
       
    26 
       
    27 CFindPerfTestStep::CFindPerfTestStep()
       
    28 	{
       
    29 	SetTestStepName(KFindPerfTestName);
       
    30 	}
       
    31 	
       
    32 // doTestStepL
       
    33 // This test fetches the memory data collected by
       
    34 // CentRep server, processes it and reports the result.
       
    35 TVerdict CFindPerfTestStep::doTestStepL()
       
    36 	{
       
    37 	SetTestStepResult(EFail);
       
    38 	
       
    39  	CRepository* repository = NULL;
       
    40 	TRAPD(res, repository = CRepository::NewL(KUidFindPerfTestRepositorySmTxt));
       
    41 	TESTL(res == KErrNone);
       
    42 	TESTL(repository != NULL);
       
    43 	CleanupStack::PushL(repository);
       
    44 
       
    45 	//if the KCentRepFindBufSize has been increased to a value more then 16 then test 
       
    46 	//repository "KUidFindPerfTestRepositorySmTxt" needs to be updated otherwise this 
       
    47 	//test will start failing. In this case the repository should be updated to have
       
    48 	//more entries.
       
    49 	TESTL(KCentRepFindBufSize<=16);
       
    50 
       
    51 	RArray<TUint32> foundIds;
       
    52 	TUint32 accumulatedTicks = 0;
       
    53 	for(TInt j=1; j<=KCentRepFindBufSize; j++)
       
    54 		{
       
    55 		accumulatedTicks = 0;
       
    56 		for(TInt i=0; i<100; i++)
       
    57 			{
       
    58 			TInt r = KErrNone;
       
    59 			TUint32 startTick = User::FastCounter();
       
    60 			r = repository->FindEqL(0, 0, j, foundIds);
       
    61 			TUint32 endTick = User::FastCounter();
       
    62 
       
    63 			//check for errors
       
    64 			TESTL(r == KErrNone);
       
    65 			//check that number of found ids is as expected
       
    66 			TESTL(foundIds.Count() == j);
       
    67 						
       
    68 			accumulatedTicks += endTick - startTick;
       
    69 			}
       
    70 		
       
    71 		INFO_PRINTF3(_L("Total time spent to find settings of count %d is %f[ms]"), j, FastCountToMillisecondsInReal(accumulatedTicks));
       
    72 		}
       
    73 
       
    74 	//now run it one more time for settings of count more than KCentRepFindBufSize
       
    75 	for(TInt j=1; j<=KCentRepFindBufSize; j++)
       
    76 		{
       
    77 		accumulatedTicks = 0;
       
    78 		for(TInt i=0; i<100; i++)
       
    79 			{
       
    80 			TInt r = KErrNone;
       
    81 			TUint32 startTick = User::FastCounter();
       
    82 			r = repository->FindNeqL(0, 0, j, foundIds);
       
    83 			TUint32 endTick = User::FastCounter();
       
    84 			
       
    85 			//check for errors
       
    86 			TESTL(r == KErrNone);
       
    87 			//check that number of found ids is as expected
       
    88 			TESTL(foundIds.Count() > KCentRepFindBufSize);
       
    89 			
       
    90 			accumulatedTicks += endTick - startTick;
       
    91 			}
       
    92 		
       
    93 		INFO_PRINTF3(_L("Total time spent to find settings of count %d is %f[ms]"), foundIds.Count(), FastCountToMillisecondsInReal(accumulatedTicks));
       
    94 		}
       
    95 		
       
    96 	CleanupStack::PopAndDestroy(repository);
       
    97 	repository = NULL;
       
    98 
       
    99 	SetTestStepResult(EPass);
       
   100 	
       
   101 	return TestStepResult();
       
   102 	}
       
   103