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