sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Te_EComPerfTestStep.cpp sl@0: // Implements the performance loggr for ECOM sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include "Te_EComStartupStatePerfTestStep.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "Interface.h" sl@0: #include "EcomTestUtils.h" sl@0: sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: // Start-up urel/armv5 test limits for CS and NC are calculated using the number of DLL's added to the sl@0: // registry for Ro Internal Drives and Non RO Internal Drives respectively. sl@0: // The test limit formula used for the upper limit is: sl@0: // 50mS+(1.75mS*number of DLLs discovered) for H2 builds sl@0: // 15mS+(1mS*number of DLLs discovered) for H4 RAM (non-NAND) builds sl@0: // 125mS+(1.5mS*number of DLLs discovered) for H4 NAND builds sl@0: // 5mS+(1mS*number of DLLs discovered) for H6 RAM (non-NAND) builds sl@0: // 40mS+(1.5mS*number of DLLs discovered) for H6 NAND builds sl@0: // These figures were determined using benchmarks from the ONB&TR. sl@0: // Although these limits are passed to CheckPerformance() for non urel/armv5 testing this method sl@0: // does not test against them. It is disabled. sl@0: sl@0: const TReal KStartupLimitBaseH2RAM = 50; sl@0: const TReal KStartupLimitMultiplierH2RAM = 2.05; sl@0: sl@0: const TReal KStartupLimitBaseH4RAM = 25; sl@0: const TReal KStartupLimitMultiplierH4RAM = 1; sl@0: sl@0: const TReal KStartupLimitBaseH6RAM = 5; sl@0: const TReal KStartupLimitMultiplierH6RAM = 0.5; sl@0: sl@0: const TReal KStartupLimitBaseH4NAND = 140; sl@0: const TReal KStartupLimitMultiplierH4NAND = 1.5; sl@0: sl@0: const TReal KStartupLimitBaseH6NAND = 40; sl@0: const TReal KStartupLimitMultiplierH6NAND = 1; sl@0: sl@0: // There is no discovery at CD therefore limit is fixed. sl@0: const TReal KCriticalDynamicLimitH2RAM = 10; sl@0: const TReal KCriticalDynamicLimitH4RAM = 2; sl@0: const TReal KCriticalDynamicLimitH4NAND = 5; sl@0: const TReal KCriticalDynamicLimitH6RAM = 1; sl@0: const TReal KCriticalDynamicLimitH6NAND = 2.5; sl@0: sl@0: // Initialisation limit is independant of DLL count and is also fixed sl@0: const TReal KInitialisationLimitH2RAM = 50; sl@0: const TReal KInitialisationLimitH4RAM = 25; sl@0: const TReal KInitialisationLimitH4NAND = 25; sl@0: const TReal KInitialisationLimitH6RAM = 5; sl@0: const TReal KInitialisationLimitH6NAND = 5; sl@0: sl@0: #endif //__ECOM_SERVER_PERFORMANCE__ sl@0: sl@0: CEComStartupStatePerfTest::CEComStartupStatePerfTest() : CEComPerfTestBase(KEComStartupStatePerfTest) sl@0: /** sl@0: * Constructor sl@0: */ sl@0: { sl@0: // does nothing here. sl@0: } sl@0: sl@0: CEComStartupStatePerfTest::~CEComStartupStatePerfTest() sl@0: /** sl@0: * Destructor sl@0: */ sl@0: { sl@0: // does nothing here. sl@0: } sl@0: sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: void CEComStartupStatePerfTest::RetrieveRegistryCountL( sl@0: RegistryCounts::TRegistryCounts::TRegistryCountDriveType aDriveType, sl@0: RegistryCounts::TRegistryCounts& aCounts, sl@0: TPtrC aMessage) sl@0: { sl@0: RegistryCounts::GetRegistryCountsL(aDriveType, aCounts); sl@0: INFO_PRINTF3(_L("Drive count for %S: [%d]"), &aMessage, aCounts.iDrives); sl@0: INFO_PRINTF3(_L("DLL count for %S: [%d]"), &aMessage, aCounts.iDlls); sl@0: INFO_PRINTF3(_L("Interface count for %S: [%d]"), &aMessage, aCounts.iInterfaces); sl@0: INFO_PRINTF3(_L("Implementation count for %S: [%d]\n"), &aMessage, aCounts.iImplementations); sl@0: } sl@0: sl@0: TVerdict CEComStartupStatePerfTest::ProcessState(RStartupStateTimerResults& aTimerResults, sl@0: TInt aTimerState, sl@0: TReal& aStateStartTime, sl@0: TReal& aStateComplTime) sl@0: { sl@0: TInt idx = aTimerResults.FindInOrderTimerResult(aTimerState); sl@0: sl@0: if(idx == KErrNotFound) sl@0: { sl@0: INFO_PRINTF1(_L("Something went wrong......whoops\n")); sl@0: SetTestStepResult(EFail); sl@0: return EFail; sl@0: } sl@0: sl@0: const TStartupStateTimerResult& timerResult = aTimerResults.At(idx); sl@0: aStateStartTime = timerResult.iStartTime; sl@0: aStateComplTime = timerResult.iEndTime; sl@0: sl@0: INFO_PRINTF3(_L("State: %d elapsed time: %f mSecs\n"), aTimerState, aStateComplTime - aStateStartTime); sl@0: sl@0: return EPass; sl@0: } sl@0: sl@0: TVerdict CEComStartupStatePerfTest::ProcessState(REComHeapUsageRecords& aHeapResults, TInt aState,TInt& aHeapUsage) sl@0: { sl@0: TInt heap=aHeapResults.GetHeapUsageAtState(aState); sl@0: if (heap==KErrNotFound) sl@0: { sl@0: INFO_PRINTF1(_L("Something went wrong......whoops\n")); sl@0: SetTestStepResult(EFail); sl@0: return EFail; sl@0: } sl@0: aHeapUsage=heap; sl@0: INFO_PRINTF3(_L("State: %d heap usage: %d bytes\n"), aState,aHeapUsage); sl@0: return EPass; sl@0: } sl@0: sl@0: #endif //__ECOM_SERVER_PERFORMANCE__ sl@0: sl@0: /* sl@0: 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: @return EPass if the test succeeds and the measured times are within the maximumum, EFail otherwise sl@0: */ sl@0: TVerdict CEComStartupStatePerfTest::doTestStepL() sl@0: { sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: sl@0: // get the registry counts from the server sl@0: // the DLL count is used to set the test limits for the startup tests sl@0: INFO_PRINTF1(_L("RO Internal Registry Counts")); sl@0: RegistryCounts::TRegistryCounts roIntCounts; sl@0: RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::ERoInternal, roIntCounts, _L("RO internal drives")); sl@0: sl@0: INFO_PRINTF1(_L("Non RO Internal Registry Counts")); sl@0: RegistryCounts::TRegistryCounts nonRoIntCounts; sl@0: RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::ENonRoInternal, nonRoIntCounts, _L("Non RO internal drives")); sl@0: sl@0: INFO_PRINTF1(_L("All Registry Counts")); sl@0: RegistryCounts::TRegistryCounts allCounts; sl@0: RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::EAll, allCounts, _L("All drives")); sl@0: sl@0: //set configuration-dependent timing limits sl@0: TReal CriticalStaticLimit = 0; sl@0: TReal NonCriticalLimit = 0; sl@0: TReal CriticalDynamicLimit = 0; sl@0: TReal InitialisationLimit = 0; sl@0: sl@0: THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration(); sl@0: switch (hardware_configuration) sl@0: { sl@0: case EPlatformH2RAM: sl@0: CriticalStaticLimit = KStartupLimitBaseH2RAM + (KStartupLimitMultiplierH2RAM * roIntCounts.iDlls); sl@0: NonCriticalLimit = KStartupLimitBaseH2RAM + (KStartupLimitMultiplierH2RAM * nonRoIntCounts.iDlls); sl@0: CriticalDynamicLimit = KCriticalDynamicLimitH2RAM; sl@0: InitialisationLimit = KInitialisationLimitH2RAM; sl@0: INFO_PRINTF1(_L("Hardware configuration: H2 RAM")); sl@0: break; sl@0: sl@0: case EPlatformH2NAND: sl@0: INFO_PRINTF1(_L("Hardware configuration: H2 NAND")); sl@0: INFO_PRINTF1(_L("***Performance testing on H2 NAND is not supported!***")); sl@0: SetTestStepResult(EFail); sl@0: break; sl@0: sl@0: case EPlatformH2NANDDP: sl@0: INFO_PRINTF1(_L("Hardware configuration: H2 NAND DP")); sl@0: INFO_PRINTF1(_L("***Performance testing on H2 NAND DP is not supported!***")); sl@0: SetTestStepResult(EFail); sl@0: break; sl@0: sl@0: case EPlatformH4RAM: sl@0: CriticalStaticLimit = KStartupLimitBaseH4RAM + (KStartupLimitMultiplierH4RAM * roIntCounts.iDlls); sl@0: NonCriticalLimit = KStartupLimitBaseH4RAM + (KStartupLimitMultiplierH4RAM * nonRoIntCounts.iDlls); sl@0: CriticalDynamicLimit = KCriticalDynamicLimitH4RAM; sl@0: InitialisationLimit = KInitialisationLimitH4RAM; sl@0: INFO_PRINTF1(_L("Hardware configuration: H4 RAM")); sl@0: break; sl@0: sl@0: case EPlatformH4NAND: sl@0: CriticalStaticLimit = KStartupLimitBaseH4NAND + (KStartupLimitMultiplierH4NAND * roIntCounts.iDlls); sl@0: NonCriticalLimit = KStartupLimitBaseH4NAND + (KStartupLimitMultiplierH4NAND * nonRoIntCounts.iDlls); sl@0: CriticalDynamicLimit = KCriticalDynamicLimitH4NAND; sl@0: InitialisationLimit = KInitialisationLimitH4NAND; sl@0: INFO_PRINTF1(_L("Hardware configuration: H4 NAND")); sl@0: break; sl@0: sl@0: case EPlatformH4NANDDP: sl@0: INFO_PRINTF1(_L("Hardware configuration: H4 NAND DP")); sl@0: break; sl@0: sl@0: case EPlatformH6RAM: sl@0: CriticalStaticLimit = KStartupLimitBaseH6RAM + (KStartupLimitMultiplierH6RAM * roIntCounts.iDlls); sl@0: NonCriticalLimit = KStartupLimitBaseH6RAM + (KStartupLimitMultiplierH6RAM * nonRoIntCounts.iDlls); sl@0: CriticalDynamicLimit = KCriticalDynamicLimitH6RAM; sl@0: InitialisationLimit = KInitialisationLimitH6RAM; sl@0: INFO_PRINTF1(_L("Hardware configuration: H6 RAM")); sl@0: break; sl@0: sl@0: case EPlatformH6NAND: sl@0: CriticalStaticLimit = KStartupLimitBaseH6NAND + (KStartupLimitMultiplierH6NAND * roIntCounts.iDlls); sl@0: NonCriticalLimit = KStartupLimitBaseH6NAND + (KStartupLimitMultiplierH6NAND * nonRoIntCounts.iDlls); sl@0: CriticalDynamicLimit = KCriticalDynamicLimitH6NAND; sl@0: InitialisationLimit = KInitialisationLimitH6NAND; sl@0: INFO_PRINTF1(_L("Hardware configuration: H6 NAND")); sl@0: break; sl@0: sl@0: case EPlatformH6NANDDP: sl@0: INFO_PRINTF1(_L("Hardware configuration: H6 NAND DP")); sl@0: break; sl@0: sl@0: case EPlatformWINSCW: sl@0: INFO_PRINTF1(_L("Hardware configuration: WINSCW")); sl@0: break; sl@0: sl@0: default: sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("***Unrecognized platform!***")); sl@0: break; sl@0: } sl@0: sl@0: // get all the timer results from the server sl@0: RStartupStateTimerResults timerResults; sl@0: timerResults.GetAllTimerResults(); sl@0: sl@0: // Get ecom start time and state. The state is a test state and should be -1 sl@0: TInt idx = timerResults.FindInOrderTimerResult(-1); sl@0: if(idx == KErrNotFound) sl@0: { sl@0: INFO_PRINTF1(_L("Something went wrong......whoops\n")); sl@0: SetTestStepResult(EFail); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TStartupStateTimerResult timerResult = timerResults.At(idx); sl@0: TReal ecomStartTime = timerResult.iStartTime; sl@0: TReal ecomComplTime = timerResult.iEndTime; sl@0: TReal stateStartTime = 0.0; sl@0: TReal stateComplTime = 0.0; sl@0: TReal accumulatedTime = 0.0; sl@0: TReal initialisationTime = 0.0; sl@0: sl@0: //Test for Critical Static state sl@0: INFO_PRINTF1(_L("Critical Static")); sl@0: TVerdict result = ProcessState(timerResults, EStartupStateCriticalStatic, stateStartTime, stateComplTime); sl@0: if(result != EPass && result != EIgnore) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: accumulatedTime += (stateComplTime - stateStartTime); sl@0: CheckPerformance(stateComplTime - stateStartTime, CriticalStaticLimit, _L("Critical static state")); sl@0: sl@0: //Test for initialisation sl@0: initialisationTime = ecomComplTime - ecomStartTime - accumulatedTime; sl@0: INFO_PRINTF2(_L("Initialisation Elapsed: %f mSecs\n"), ecomComplTime - ecomStartTime); sl@0: accumulatedTime += initialisationTime; sl@0: CheckPerformance(initialisationTime, InitialisationLimit, _L("Initialisation Time")); sl@0: sl@0: //Test for Critical Dynamic state sl@0: result = ProcessState(timerResults, EStartupStateCriticalDynamic, stateStartTime, stateComplTime); sl@0: if(result != EPass && result != EIgnore) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: accumulatedTime += (stateComplTime - stateStartTime); sl@0: CheckPerformance(stateComplTime - stateStartTime, CriticalDynamicLimit, _L("Critical dynamic state")); sl@0: sl@0: //Test for Non Critical state sl@0: result = ProcessState(timerResults, EStartupStateNonCritical, stateStartTime, stateComplTime); sl@0: if(result != EPass && result != EIgnore) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: accumulatedTime += (stateComplTime - stateStartTime); sl@0: CheckPerformance(stateComplTime - stateStartTime, NonCriticalLimit, _L("Non critical state")); sl@0: sl@0: //Test for overall time sl@0: INFO_PRINTF2(_L("Ecom Stop Time: %f mSecs\n"), stateComplTime); sl@0: INFO_PRINTF2(_L("Total Elapsed Time: %f mSecs\n"), stateComplTime - ecomStartTime); sl@0: INFO_PRINTF2(_L("Total Accumulated Time: %f mSecs\n"), accumulatedTime); sl@0: // CheckPerformance(accumulatedTime, 1000); Test unecessary as individual times that make up accumulated are already tested sl@0: sl@0: // Now get all the heap results from the server sl@0: REComHeapUsageRecords heapResults; sl@0: heapResults.OpenL(); sl@0: sl@0: //Test for Critical Static state sl@0: TInt CSUsage=0; sl@0: INFO_PRINTF1(_L("Critical Static state")); sl@0: result=ProcessState(heapResults,EStartupStateCriticalStatic,CSUsage); sl@0: if(result != EPass && result != EIgnore) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: //Test for initialisation sl@0: INFO_PRINTF1(_L("Initialisation state(including Critical Static measurement)")); sl@0: TInt heapUsage=0; sl@0: result=ProcessState(heapResults,-1,heapUsage); sl@0: TInt initialisationHeapUsage=heapUsage-CSUsage; sl@0: if(result != EPass && result != EIgnore) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: INFO_PRINTF1(_L("Initialisation state(excluding Critical Static measurement)")); sl@0: INFO_PRINTF3(_L("State: %d heap usage: %d bytes\n"), -1,initialisationHeapUsage); sl@0: sl@0: //Test for Critical Dynamic state sl@0: INFO_PRINTF1(_L("Critical Dynamic state")); sl@0: result=ProcessState(heapResults,EStartupStateCriticalDynamic,heapUsage); sl@0: if(result != EPass && result != EIgnore) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: //Test for Non Critical State sl@0: INFO_PRINTF1(_L("Non Critical sate")); sl@0: result=ProcessState(heapResults,EStartupStateNonCritical,heapUsage); sl@0: if(result != EPass && result != EIgnore) sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: heapResults.Close(); sl@0: #else sl@0: MacroNotDefinedError(); sl@0: #endif // __ECOM_SERVER_PERFORMANCE__ sl@0: return TestStepResult(); sl@0: }