os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComStartupStatePerfTestStep.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 // Te_EComPerfTestStep.cpp
    15 // Implements the performance loggr for ECOM
    16 // 
    17 //
    18 
    19 /**
    20  @file
    21  @internalComponent
    22 */
    23 
    24 #include "Te_EComStartupStatePerfTestStep.h"
    25 #include <e32test.h>
    26 #include <f32file.h>
    27 #include <bautils.h>
    28 #include <startup.hrh>
    29 #include <ecom/ecom.h>
    30 #include "Interface.h"
    31 #include "EcomTestUtils.h"
    32 
    33 #ifdef __ECOM_SERVER_PERFORMANCE__
    34 // Start-up urel/armv5 test limits for CS and NC are calculated using the number of DLL's added to the
    35 // registry for Ro Internal Drives and Non RO Internal Drives respectively.
    36 // The test limit formula used for the upper limit is:
    37 // 50mS+(1.75mS*number of DLLs discovered) for H2 builds 
    38 // 15mS+(1mS*number of DLLs discovered) for H4 RAM (non-NAND) builds
    39 // 125mS+(1.5mS*number of DLLs discovered) for H4 NAND builds 
    40 // 5mS+(1mS*number of DLLs discovered) for H6 RAM (non-NAND) builds  
    41 // 40mS+(1.5mS*number of DLLs discovered) for H6 NAND builds   
    42 // These figures were determined using benchmarks from the ONB&TR.
    43 // Although these limits are passed to CheckPerformance() for non urel/armv5 testing this method
    44 // does not test against them. It is disabled.
    45 
    46 const TReal KStartupLimitBaseH2RAM = 50;
    47 const TReal KStartupLimitMultiplierH2RAM = 2.05;
    48 
    49 const TReal KStartupLimitBaseH4RAM = 25;
    50 const TReal KStartupLimitMultiplierH4RAM = 1;
    51 
    52 const TReal KStartupLimitBaseH6RAM = 5;
    53 const TReal KStartupLimitMultiplierH6RAM = 0.5;
    54 
    55 const TReal KStartupLimitBaseH4NAND = 140;
    56 const TReal KStartupLimitMultiplierH4NAND = 1.5;
    57 
    58 const TReal KStartupLimitBaseH6NAND = 40;
    59 const TReal KStartupLimitMultiplierH6NAND = 1;
    60 
    61 // There is no discovery at CD therefore limit is fixed.
    62 const TReal KCriticalDynamicLimitH2RAM = 10;
    63 const TReal KCriticalDynamicLimitH4RAM = 2;
    64 const TReal KCriticalDynamicLimitH4NAND = 5;
    65 const TReal KCriticalDynamicLimitH6RAM = 1;
    66 const TReal KCriticalDynamicLimitH6NAND = 2.5;
    67 
    68 // Initialisation limit is independant of DLL count and is also fixed
    69 const TReal KInitialisationLimitH2RAM = 50;
    70 const TReal KInitialisationLimitH4RAM = 25;
    71 const TReal KInitialisationLimitH4NAND = 25;
    72 const TReal KInitialisationLimitH6RAM = 5;
    73 const TReal KInitialisationLimitH6NAND = 5;
    74 
    75 #endif //__ECOM_SERVER_PERFORMANCE__
    76 
    77 CEComStartupStatePerfTest::CEComStartupStatePerfTest() : CEComPerfTestBase(KEComStartupStatePerfTest)
    78 /**
    79  * Constructor
    80  */
    81 	{
    82 	// does nothing here.
    83 	}
    84 
    85 CEComStartupStatePerfTest::~CEComStartupStatePerfTest()
    86 /**
    87  * Destructor
    88  */
    89 	{
    90 	// does nothing here.
    91 	}
    92 
    93 #ifdef __ECOM_SERVER_PERFORMANCE__
    94 void CEComStartupStatePerfTest::RetrieveRegistryCountL(
    95 		RegistryCounts::TRegistryCounts::TRegistryCountDriveType aDriveType,
    96 		RegistryCounts::TRegistryCounts& aCounts,
    97 		TPtrC aMessage)
    98 	{
    99 	RegistryCounts::GetRegistryCountsL(aDriveType, aCounts);
   100 	INFO_PRINTF3(_L("Drive count for %S: [%d]"), &aMessage, aCounts.iDrives);
   101 	INFO_PRINTF3(_L("DLL count for %S: [%d]"), &aMessage, aCounts.iDlls);
   102 	INFO_PRINTF3(_L("Interface count for %S: [%d]"), &aMessage, aCounts.iInterfaces);
   103 	INFO_PRINTF3(_L("Implementation count for %S: [%d]\n"), &aMessage, aCounts.iImplementations);
   104 	}
   105 
   106 TVerdict CEComStartupStatePerfTest::ProcessState(RStartupStateTimerResults& aTimerResults, 
   107 		TInt aTimerState, 
   108 		TReal& aStateStartTime, 
   109 		TReal& aStateComplTime)
   110 	{
   111 	TInt idx = aTimerResults.FindInOrderTimerResult(aTimerState);
   112 
   113 	if(idx == KErrNotFound)
   114 	 	{
   115  		INFO_PRINTF1(_L("Something went wrong......whoops\n"));
   116 	 	SetTestStepResult(EFail);
   117 	 	return EFail;
   118 	 	}
   119 	
   120 	const TStartupStateTimerResult& timerResult = aTimerResults.At(idx);
   121 	aStateStartTime = timerResult.iStartTime;
   122 	aStateComplTime = timerResult.iEndTime;
   123 	
   124 	INFO_PRINTF3(_L("State: %d elapsed time: %f mSecs\n"), aTimerState, aStateComplTime - aStateStartTime);
   125 	
   126 	return EPass;
   127 	}
   128 	
   129 TVerdict CEComStartupStatePerfTest::ProcessState(REComHeapUsageRecords& aHeapResults, TInt aState,TInt& aHeapUsage)
   130 	{
   131 	TInt heap=aHeapResults.GetHeapUsageAtState(aState);
   132 	if (heap==KErrNotFound)
   133 		{
   134  		INFO_PRINTF1(_L("Something went wrong......whoops\n"));
   135 	 	SetTestStepResult(EFail);
   136 	 	return EFail;		
   137 		}
   138 	aHeapUsage=heap;
   139 	INFO_PRINTF3(_L("State: %d heap usage: %d bytes\n"), aState,aHeapUsage);	
   140 	return EPass;
   141 	}
   142 	
   143 #endif //__ECOM_SERVER_PERFORMANCE__
   144 	
   145 /*
   146  Retrieves startup state timing from the ECom server and tests that the time spent during the different startup states is within a set of maximum bounds
   147  @return EPass if the test succeeds and the measured times are within the maximumum, EFail otherwise
   148  */
   149 TVerdict CEComStartupStatePerfTest::doTestStepL()
   150 	{
   151 #ifdef __ECOM_SERVER_PERFORMANCE__
   152 
   153 	// get the registry counts from the server
   154 	// the DLL count is used to set the test limits for the startup tests
   155 	INFO_PRINTF1(_L("RO Internal Registry Counts"));
   156 	RegistryCounts::TRegistryCounts roIntCounts;
   157 	RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::ERoInternal, roIntCounts, _L("RO internal drives"));
   158 
   159 	INFO_PRINTF1(_L("Non RO Internal Registry Counts"));
   160 	RegistryCounts::TRegistryCounts nonRoIntCounts;
   161 	RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::ENonRoInternal, nonRoIntCounts, _L("Non RO internal drives"));
   162 
   163 	INFO_PRINTF1(_L("All Registry Counts"));
   164 	RegistryCounts::TRegistryCounts allCounts;
   165 	RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::EAll, allCounts, _L("All drives"));
   166    
   167 	//set configuration-dependent timing limits
   168 	TReal CriticalStaticLimit = 0;
   169 	TReal NonCriticalLimit = 0;
   170 	TReal CriticalDynamicLimit = 0;
   171 	TReal InitialisationLimit = 0;
   172 
   173 	THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration();
   174 	switch (hardware_configuration)
   175 		{
   176 		case EPlatformH2RAM:
   177 	    	CriticalStaticLimit = KStartupLimitBaseH2RAM + (KStartupLimitMultiplierH2RAM * roIntCounts.iDlls);
   178 			NonCriticalLimit = KStartupLimitBaseH2RAM + (KStartupLimitMultiplierH2RAM * nonRoIntCounts.iDlls);
   179 			CriticalDynamicLimit = KCriticalDynamicLimitH2RAM;
   180 			InitialisationLimit = KInitialisationLimitH2RAM;
   181 			INFO_PRINTF1(_L("Hardware configuration: H2 RAM"));
   182 			break;
   183 		
   184 		case EPlatformH2NAND:		
   185 			INFO_PRINTF1(_L("Hardware configuration: H2 NAND"));
   186 			INFO_PRINTF1(_L("***Performance testing on H2 NAND is not supported!***"));
   187 			SetTestStepResult(EFail);			
   188 			break;
   189 			
   190 		case EPlatformH2NANDDP:
   191 			INFO_PRINTF1(_L("Hardware configuration: H2 NAND DP"));
   192 			INFO_PRINTF1(_L("***Performance testing on H2 NAND DP is not supported!***"));
   193 			SetTestStepResult(EFail);			
   194 			break;
   195 		
   196 		case EPlatformH4RAM:
   197 			CriticalStaticLimit = KStartupLimitBaseH4RAM + (KStartupLimitMultiplierH4RAM * roIntCounts.iDlls);
   198 			NonCriticalLimit = KStartupLimitBaseH4RAM + (KStartupLimitMultiplierH4RAM * nonRoIntCounts.iDlls);
   199 			CriticalDynamicLimit = KCriticalDynamicLimitH4RAM;
   200 			InitialisationLimit = KInitialisationLimitH4RAM;
   201 			INFO_PRINTF1(_L("Hardware configuration: H4 RAM"));
   202 			break;
   203 							
   204 		case EPlatformH4NAND:		
   205 			CriticalStaticLimit = KStartupLimitBaseH4NAND + (KStartupLimitMultiplierH4NAND * roIntCounts.iDlls);
   206 			NonCriticalLimit = KStartupLimitBaseH4NAND + (KStartupLimitMultiplierH4NAND * nonRoIntCounts.iDlls);
   207 			CriticalDynamicLimit = KCriticalDynamicLimitH4NAND;
   208 			InitialisationLimit = KInitialisationLimitH4NAND;
   209 			INFO_PRINTF1(_L("Hardware configuration: H4 NAND"));
   210 			break;
   211 		
   212 		case EPlatformH4NANDDP:	
   213 			INFO_PRINTF1(_L("Hardware configuration: H4 NAND DP"));
   214 			break;
   215 
   216 		case EPlatformH6RAM:
   217 			CriticalStaticLimit = KStartupLimitBaseH6RAM + (KStartupLimitMultiplierH6RAM * roIntCounts.iDlls);
   218 			NonCriticalLimit = KStartupLimitBaseH6RAM + (KStartupLimitMultiplierH6RAM * nonRoIntCounts.iDlls);
   219 			CriticalDynamicLimit = KCriticalDynamicLimitH6RAM;
   220 			InitialisationLimit = KInitialisationLimitH6RAM;
   221 			INFO_PRINTF1(_L("Hardware configuration: H6 RAM"));
   222 			break;
   223 							
   224 		case EPlatformH6NAND:		
   225 			CriticalStaticLimit = KStartupLimitBaseH6NAND + (KStartupLimitMultiplierH6NAND * roIntCounts.iDlls);
   226 			NonCriticalLimit = KStartupLimitBaseH6NAND + (KStartupLimitMultiplierH6NAND * nonRoIntCounts.iDlls);
   227 			CriticalDynamicLimit = KCriticalDynamicLimitH6NAND;
   228 			InitialisationLimit = KInitialisationLimitH6NAND;
   229 			INFO_PRINTF1(_L("Hardware configuration: H6 NAND"));
   230 			break;
   231 		
   232 		case EPlatformH6NANDDP:	
   233 			INFO_PRINTF1(_L("Hardware configuration: H6 NAND DP"));
   234 			break;
   235 					
   236 		case EPlatformWINSCW:
   237 			INFO_PRINTF1(_L("Hardware configuration: WINSCW"));
   238 			break;
   239 		
   240 		default:		
   241 			SetTestStepResult(EFail);
   242 			INFO_PRINTF1(_L("***Unrecognized platform!***"));
   243 			break;		
   244 		}
   245 		
   246 	// get all the timer results from the server
   247 	RStartupStateTimerResults timerResults;
   248 	timerResults.GetAllTimerResults();
   249 	
   250 	// Get ecom start time and state. The state is a test state and should be -1 
   251 	TInt idx = timerResults.FindInOrderTimerResult(-1);
   252 	if(idx == KErrNotFound)
   253 	 	{
   254  		INFO_PRINTF1(_L("Something went wrong......whoops\n"));
   255 	 	SetTestStepResult(EFail);
   256 	 	return TestStepResult();
   257 	 	}
   258 
   259 	TStartupStateTimerResult timerResult = timerResults.At(idx);
   260 	TReal ecomStartTime = timerResult.iStartTime;
   261 	TReal ecomComplTime = timerResult.iEndTime;
   262 	TReal stateStartTime = 0.0;
   263 	TReal stateComplTime = 0.0;
   264 	TReal accumulatedTime = 0.0;
   265 	TReal initialisationTime = 0.0;
   266 	
   267 	//Test for Critical Static state
   268 	INFO_PRINTF1(_L("Critical Static"));
   269 	TVerdict result = ProcessState(timerResults, EStartupStateCriticalStatic, stateStartTime, stateComplTime);
   270 	if(result != EPass && result != EIgnore)
   271 		{
   272 		return TestStepResult();
   273 		}
   274 	accumulatedTime += (stateComplTime - stateStartTime);
   275 	CheckPerformance(stateComplTime - stateStartTime, CriticalStaticLimit, _L("Critical static state"));
   276 	
   277 	//Test for initialisation
   278 	initialisationTime = ecomComplTime - ecomStartTime - accumulatedTime;
   279 	INFO_PRINTF2(_L("Initialisation Elapsed: %f mSecs\n"), ecomComplTime - ecomStartTime);
   280 	accumulatedTime += initialisationTime;
   281 	CheckPerformance(initialisationTime, InitialisationLimit, _L("Initialisation Time"));
   282 
   283 	//Test for Critical Dynamic state
   284 	result = ProcessState(timerResults, EStartupStateCriticalDynamic, stateStartTime, stateComplTime);
   285 	if(result != EPass && result != EIgnore)
   286 		{
   287 		return TestStepResult();
   288 		}
   289 	accumulatedTime += (stateComplTime - stateStartTime);
   290 	CheckPerformance(stateComplTime - stateStartTime, CriticalDynamicLimit, _L("Critical dynamic state"));
   291 
   292 	//Test for Non Critical state
   293 	result = ProcessState(timerResults, EStartupStateNonCritical, stateStartTime, stateComplTime);
   294 	if(result != EPass && result != EIgnore)
   295 		{
   296 		return TestStepResult();
   297 		}
   298 	accumulatedTime += (stateComplTime - stateStartTime);
   299 	CheckPerformance(stateComplTime - stateStartTime, NonCriticalLimit, _L("Non critical state"));
   300 
   301 	//Test for overall time
   302 	INFO_PRINTF2(_L("Ecom Stop Time: %f mSecs\n"), stateComplTime);
   303 	INFO_PRINTF2(_L("Total Elapsed Time: %f mSecs\n"), stateComplTime - ecomStartTime);
   304 	INFO_PRINTF2(_L("Total Accumulated Time: %f mSecs\n"), 	accumulatedTime);
   305 	// CheckPerformance(accumulatedTime, 1000); Test unecessary as individual times that make up accumulated are already tested
   306 	
   307 	// Now get all the heap results from the server
   308 	REComHeapUsageRecords heapResults;
   309 	heapResults.OpenL();	
   310 
   311 	//Test for Critical Static state
   312 	TInt CSUsage=0;
   313 	INFO_PRINTF1(_L("Critical Static state"));
   314 	result=ProcessState(heapResults,EStartupStateCriticalStatic,CSUsage);
   315 	if(result != EPass && result != EIgnore)
   316 		{
   317 		return TestStepResult();
   318 		}
   319 	//Test for initialisation
   320 	INFO_PRINTF1(_L("Initialisation state(including Critical Static measurement)"));
   321 	TInt heapUsage=0;
   322 	result=ProcessState(heapResults,-1,heapUsage);
   323 	TInt initialisationHeapUsage=heapUsage-CSUsage;
   324 	if(result != EPass && result != EIgnore)
   325 		{
   326 		return TestStepResult();
   327 		}
   328 	INFO_PRINTF1(_L("Initialisation state(excluding Critical Static measurement)"));	
   329 	INFO_PRINTF3(_L("State: %d heap usage: %d bytes\n"), -1,initialisationHeapUsage);			
   330 					
   331 	//Test for Critical Dynamic state
   332 	INFO_PRINTF1(_L("Critical Dynamic state"));	
   333 	result=ProcessState(heapResults,EStartupStateCriticalDynamic,heapUsage);
   334 	if(result != EPass && result != EIgnore)
   335 		{
   336 		return TestStepResult();
   337 		}	
   338 	
   339 	//Test for Non Critical State
   340 	INFO_PRINTF1(_L("Non Critical sate"));
   341 	result=ProcessState(heapResults,EStartupStateNonCritical,heapUsage);
   342 	if(result != EPass && result != EIgnore)
   343 		{
   344 		return TestStepResult();
   345 		}
   346 				
   347 	heapResults.Close();	
   348 #else
   349 	MacroNotDefinedError();
   350 #endif // __ECOM_SERVER_PERFORMANCE__
   351 	return TestStepResult();
   352 	}