persistentstorage/centralrepository/test/testexecute/performance/src/TE_PerfTestCompareStep.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_PerfTestCompareStep.h"
       
    17 #include "t_cenrep_helper.h"
       
    18 #include <centralrepository.h>
       
    19 #include "srvreqs.h"
       
    20 #include "srvdefs.h"
       
    21 #include "cachemgr.h"
       
    22 
       
    23 //--------------------------------
       
    24 // class CPerfTestCompareStep
       
    25 //--------------------------------
       
    26 
       
    27 CPerfTestCompareStep::CPerfTestCompareStep() 
       
    28 	{
       
    29 	SetTestStepName(KPerfTestCompareStep);
       
    30 	}
       
    31 
       
    32 // doTestStepL
       
    33 // Implement the pure virtual function.
       
    34 // Comapre the results of previous timing tests
       
    35 TVerdict CPerfTestCompareStep::doTestStepL()
       
    36 	{
       
    37 #ifndef __CENTREP_SERVER_CACHETEST__
       
    38 	return EPass;
       
    39 #else	
       
    40     SetTestStepResult(EFail);
       
    41 
       
    42 	// To make sure future tests in this harness run under caching
       
    43 	TInt r = SetGetParameters(TIpcArgs(EEnableCache, KDefaultEvictionTimeout, KDefaultCacheSize));
       
    44 
       
    45 	TPtrC resultSection1;
       
    46 	_LIT(KSharedName1, "shared_name_1");
       
    47 	TInt bRet = GetStringFromConfig(ConfigSection(), KSharedName1, resultSection1);
       
    48 	TESTL(bRet==1);
       
    49 
       
    50 	TPtrC resultSection2;
       
    51 	_LIT(KSharedName2, "shared_name_2");
       
    52 	bRet = GetStringFromConfig(ConfigSection(), KSharedName2, resultSection2);
       
    53 	TESTL(bRet==1);
       
    54 	
       
    55 	TBuf<KMaxFileName> sharedString; 
       
    56 		
       
    57 	ReadSharedDataL(resultSection1, sharedString);
       
    58 	
       
    59 	ReadResults(iResults1, sharedString);
       
    60 	sharedString.Zero();
       
    61 	ReadSharedDataL(resultSection2, sharedString);
       
    62 	ReadResults(iResults2, sharedString);
       
    63 	
       
    64 	TESTL(iResults1.Count()==iResults2.Count());
       
    65 	
       
    66 	for(TInt i=0; i<iResults1.Count(); i++)
       
    67 		{
       
    68 		TESTL(iResults1[i].iUseCount==iResults2[i].iUseCount);
       
    69 #if defined __WINS__ || defined __WINSCW__
       
    70 		// This test is deactivated for emulator builds.
       
    71       		// Emulator build runs produce inconsistent results when running this 
       
    72 	      	// test on ONB machines, probably because of uncontrolled CPU and disk 
       
    73       		// activity on the host system caused by previous build and test commands
       
    74 #else	
       
    75 		// Expect an increase in performance
       
    76 		TESTL(iResults1[i].iSumElapsedTicks<iResults2[i].iSumElapsedTicks);
       
    77 #endif
       
    78 		}
       
    79 	
       
    80 	SetTestStepResult(EPass);		
       
    81 	
       
    82 	return TestStepResult();
       
    83 #endif //__CENTREP_SERVER_CACHETEST__	
       
    84 	}
       
    85 
       
    86 void CPerfTestCompareStep::ReadResults(RArray<TSummary>& aArray, TBuf<KMaxFileName>& aString) 
       
    87 	{
       
    88 	TLex analyse(aString);
       
    89 	
       
    90 	TInt items;
       
    91 	TSummary summary;	
       
    92 
       
    93 	for(TInt i=0; i<2; i++)
       
    94 		{
       
    95 		analyse.Val(items);
       
    96 		analyse.SkipSpaceAndMark();
       
    97 		for(TInt i=0;i<items;i++)
       
    98 			{
       
    99 			analyse.SkipCharacters();		
       
   100 			TPtrC token = analyse.MarkedToken();
       
   101 			summary.iName.Copy(token);
       
   102 			analyse.SkipSpaceAndMark();
       
   103 			analyse.Val(summary.iUseCount);
       
   104 			analyse.SkipSpaceAndMark();
       
   105 			analyse.Val(summary.iSumElapsedTicks,EDecimal);
       
   106 			analyse.SkipSpaceAndMark();
       
   107 			aArray.Append(summary);
       
   108 			}
       
   109 		}
       
   110 	}