os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComStartupStatePerfTestStep.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComStartupStatePerfTestStep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,352 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Te_EComPerfTestStep.cpp
1.18 +// Implements the performance loggr for ECOM
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 + @internalComponent
1.25 +*/
1.26 +
1.27 +#include "Te_EComStartupStatePerfTestStep.h"
1.28 +#include <e32test.h>
1.29 +#include <f32file.h>
1.30 +#include <bautils.h>
1.31 +#include <startup.hrh>
1.32 +#include <ecom/ecom.h>
1.33 +#include "Interface.h"
1.34 +#include "EcomTestUtils.h"
1.35 +
1.36 +#ifdef __ECOM_SERVER_PERFORMANCE__
1.37 +// Start-up urel/armv5 test limits for CS and NC are calculated using the number of DLL's added to the
1.38 +// registry for Ro Internal Drives and Non RO Internal Drives respectively.
1.39 +// The test limit formula used for the upper limit is:
1.40 +// 50mS+(1.75mS*number of DLLs discovered) for H2 builds
1.41 +// 15mS+(1mS*number of DLLs discovered) for H4 RAM (non-NAND) builds
1.42 +// 125mS+(1.5mS*number of DLLs discovered) for H4 NAND builds
1.43 +// 5mS+(1mS*number of DLLs discovered) for H6 RAM (non-NAND) builds
1.44 +// 40mS+(1.5mS*number of DLLs discovered) for H6 NAND builds
1.45 +// These figures were determined using benchmarks from the ONB&TR.
1.46 +// Although these limits are passed to CheckPerformance() for non urel/armv5 testing this method
1.47 +// does not test against them. It is disabled.
1.48 +
1.49 +const TReal KStartupLimitBaseH2RAM = 50;
1.50 +const TReal KStartupLimitMultiplierH2RAM = 2.05;
1.51 +
1.52 +const TReal KStartupLimitBaseH4RAM = 25;
1.53 +const TReal KStartupLimitMultiplierH4RAM = 1;
1.54 +
1.55 +const TReal KStartupLimitBaseH6RAM = 5;
1.56 +const TReal KStartupLimitMultiplierH6RAM = 0.5;
1.57 +
1.58 +const TReal KStartupLimitBaseH4NAND = 140;
1.59 +const TReal KStartupLimitMultiplierH4NAND = 1.5;
1.60 +
1.61 +const TReal KStartupLimitBaseH6NAND = 40;
1.62 +const TReal KStartupLimitMultiplierH6NAND = 1;
1.63 +
1.64 +// There is no discovery at CD therefore limit is fixed.
1.65 +const TReal KCriticalDynamicLimitH2RAM = 10;
1.66 +const TReal KCriticalDynamicLimitH4RAM = 2;
1.67 +const TReal KCriticalDynamicLimitH4NAND = 5;
1.68 +const TReal KCriticalDynamicLimitH6RAM = 1;
1.69 +const TReal KCriticalDynamicLimitH6NAND = 2.5;
1.70 +
1.71 +// Initialisation limit is independant of DLL count and is also fixed
1.72 +const TReal KInitialisationLimitH2RAM = 50;
1.73 +const TReal KInitialisationLimitH4RAM = 25;
1.74 +const TReal KInitialisationLimitH4NAND = 25;
1.75 +const TReal KInitialisationLimitH6RAM = 5;
1.76 +const TReal KInitialisationLimitH6NAND = 5;
1.77 +
1.78 +#endif //__ECOM_SERVER_PERFORMANCE__
1.79 +
1.80 +CEComStartupStatePerfTest::CEComStartupStatePerfTest() : CEComPerfTestBase(KEComStartupStatePerfTest)
1.81 +/**
1.82 + * Constructor
1.83 + */
1.84 + {
1.85 + // does nothing here.
1.86 + }
1.87 +
1.88 +CEComStartupStatePerfTest::~CEComStartupStatePerfTest()
1.89 +/**
1.90 + * Destructor
1.91 + */
1.92 + {
1.93 + // does nothing here.
1.94 + }
1.95 +
1.96 +#ifdef __ECOM_SERVER_PERFORMANCE__
1.97 +void CEComStartupStatePerfTest::RetrieveRegistryCountL(
1.98 + RegistryCounts::TRegistryCounts::TRegistryCountDriveType aDriveType,
1.99 + RegistryCounts::TRegistryCounts& aCounts,
1.100 + TPtrC aMessage)
1.101 + {
1.102 + RegistryCounts::GetRegistryCountsL(aDriveType, aCounts);
1.103 + INFO_PRINTF3(_L("Drive count for %S: [%d]"), &aMessage, aCounts.iDrives);
1.104 + INFO_PRINTF3(_L("DLL count for %S: [%d]"), &aMessage, aCounts.iDlls);
1.105 + INFO_PRINTF3(_L("Interface count for %S: [%d]"), &aMessage, aCounts.iInterfaces);
1.106 + INFO_PRINTF3(_L("Implementation count for %S: [%d]\n"), &aMessage, aCounts.iImplementations);
1.107 + }
1.108 +
1.109 +TVerdict CEComStartupStatePerfTest::ProcessState(RStartupStateTimerResults& aTimerResults,
1.110 + TInt aTimerState,
1.111 + TReal& aStateStartTime,
1.112 + TReal& aStateComplTime)
1.113 + {
1.114 + TInt idx = aTimerResults.FindInOrderTimerResult(aTimerState);
1.115 +
1.116 + if(idx == KErrNotFound)
1.117 + {
1.118 + INFO_PRINTF1(_L("Something went wrong......whoops\n"));
1.119 + SetTestStepResult(EFail);
1.120 + return EFail;
1.121 + }
1.122 +
1.123 + const TStartupStateTimerResult& timerResult = aTimerResults.At(idx);
1.124 + aStateStartTime = timerResult.iStartTime;
1.125 + aStateComplTime = timerResult.iEndTime;
1.126 +
1.127 + INFO_PRINTF3(_L("State: %d elapsed time: %f mSecs\n"), aTimerState, aStateComplTime - aStateStartTime);
1.128 +
1.129 + return EPass;
1.130 + }
1.131 +
1.132 +TVerdict CEComStartupStatePerfTest::ProcessState(REComHeapUsageRecords& aHeapResults, TInt aState,TInt& aHeapUsage)
1.133 + {
1.134 + TInt heap=aHeapResults.GetHeapUsageAtState(aState);
1.135 + if (heap==KErrNotFound)
1.136 + {
1.137 + INFO_PRINTF1(_L("Something went wrong......whoops\n"));
1.138 + SetTestStepResult(EFail);
1.139 + return EFail;
1.140 + }
1.141 + aHeapUsage=heap;
1.142 + INFO_PRINTF3(_L("State: %d heap usage: %d bytes\n"), aState,aHeapUsage);
1.143 + return EPass;
1.144 + }
1.145 +
1.146 +#endif //__ECOM_SERVER_PERFORMANCE__
1.147 +
1.148 +/*
1.149 + 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
1.150 + @return EPass if the test succeeds and the measured times are within the maximumum, EFail otherwise
1.151 + */
1.152 +TVerdict CEComStartupStatePerfTest::doTestStepL()
1.153 + {
1.154 +#ifdef __ECOM_SERVER_PERFORMANCE__
1.155 +
1.156 + // get the registry counts from the server
1.157 + // the DLL count is used to set the test limits for the startup tests
1.158 + INFO_PRINTF1(_L("RO Internal Registry Counts"));
1.159 + RegistryCounts::TRegistryCounts roIntCounts;
1.160 + RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::ERoInternal, roIntCounts, _L("RO internal drives"));
1.161 +
1.162 + INFO_PRINTF1(_L("Non RO Internal Registry Counts"));
1.163 + RegistryCounts::TRegistryCounts nonRoIntCounts;
1.164 + RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::ENonRoInternal, nonRoIntCounts, _L("Non RO internal drives"));
1.165 +
1.166 + INFO_PRINTF1(_L("All Registry Counts"));
1.167 + RegistryCounts::TRegistryCounts allCounts;
1.168 + RetrieveRegistryCountL(RegistryCounts::TRegistryCounts::EAll, allCounts, _L("All drives"));
1.169 +
1.170 + //set configuration-dependent timing limits
1.171 + TReal CriticalStaticLimit = 0;
1.172 + TReal NonCriticalLimit = 0;
1.173 + TReal CriticalDynamicLimit = 0;
1.174 + TReal InitialisationLimit = 0;
1.175 +
1.176 + THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration();
1.177 + switch (hardware_configuration)
1.178 + {
1.179 + case EPlatformH2RAM:
1.180 + CriticalStaticLimit = KStartupLimitBaseH2RAM + (KStartupLimitMultiplierH2RAM * roIntCounts.iDlls);
1.181 + NonCriticalLimit = KStartupLimitBaseH2RAM + (KStartupLimitMultiplierH2RAM * nonRoIntCounts.iDlls);
1.182 + CriticalDynamicLimit = KCriticalDynamicLimitH2RAM;
1.183 + InitialisationLimit = KInitialisationLimitH2RAM;
1.184 + INFO_PRINTF1(_L("Hardware configuration: H2 RAM"));
1.185 + break;
1.186 +
1.187 + case EPlatformH2NAND:
1.188 + INFO_PRINTF1(_L("Hardware configuration: H2 NAND"));
1.189 + INFO_PRINTF1(_L("***Performance testing on H2 NAND is not supported!***"));
1.190 + SetTestStepResult(EFail);
1.191 + break;
1.192 +
1.193 + case EPlatformH2NANDDP:
1.194 + INFO_PRINTF1(_L("Hardware configuration: H2 NAND DP"));
1.195 + INFO_PRINTF1(_L("***Performance testing on H2 NAND DP is not supported!***"));
1.196 + SetTestStepResult(EFail);
1.197 + break;
1.198 +
1.199 + case EPlatformH4RAM:
1.200 + CriticalStaticLimit = KStartupLimitBaseH4RAM + (KStartupLimitMultiplierH4RAM * roIntCounts.iDlls);
1.201 + NonCriticalLimit = KStartupLimitBaseH4RAM + (KStartupLimitMultiplierH4RAM * nonRoIntCounts.iDlls);
1.202 + CriticalDynamicLimit = KCriticalDynamicLimitH4RAM;
1.203 + InitialisationLimit = KInitialisationLimitH4RAM;
1.204 + INFO_PRINTF1(_L("Hardware configuration: H4 RAM"));
1.205 + break;
1.206 +
1.207 + case EPlatformH4NAND:
1.208 + CriticalStaticLimit = KStartupLimitBaseH4NAND + (KStartupLimitMultiplierH4NAND * roIntCounts.iDlls);
1.209 + NonCriticalLimit = KStartupLimitBaseH4NAND + (KStartupLimitMultiplierH4NAND * nonRoIntCounts.iDlls);
1.210 + CriticalDynamicLimit = KCriticalDynamicLimitH4NAND;
1.211 + InitialisationLimit = KInitialisationLimitH4NAND;
1.212 + INFO_PRINTF1(_L("Hardware configuration: H4 NAND"));
1.213 + break;
1.214 +
1.215 + case EPlatformH4NANDDP:
1.216 + INFO_PRINTF1(_L("Hardware configuration: H4 NAND DP"));
1.217 + break;
1.218 +
1.219 + case EPlatformH6RAM:
1.220 + CriticalStaticLimit = KStartupLimitBaseH6RAM + (KStartupLimitMultiplierH6RAM * roIntCounts.iDlls);
1.221 + NonCriticalLimit = KStartupLimitBaseH6RAM + (KStartupLimitMultiplierH6RAM * nonRoIntCounts.iDlls);
1.222 + CriticalDynamicLimit = KCriticalDynamicLimitH6RAM;
1.223 + InitialisationLimit = KInitialisationLimitH6RAM;
1.224 + INFO_PRINTF1(_L("Hardware configuration: H6 RAM"));
1.225 + break;
1.226 +
1.227 + case EPlatformH6NAND:
1.228 + CriticalStaticLimit = KStartupLimitBaseH6NAND + (KStartupLimitMultiplierH6NAND * roIntCounts.iDlls);
1.229 + NonCriticalLimit = KStartupLimitBaseH6NAND + (KStartupLimitMultiplierH6NAND * nonRoIntCounts.iDlls);
1.230 + CriticalDynamicLimit = KCriticalDynamicLimitH6NAND;
1.231 + InitialisationLimit = KInitialisationLimitH6NAND;
1.232 + INFO_PRINTF1(_L("Hardware configuration: H6 NAND"));
1.233 + break;
1.234 +
1.235 + case EPlatformH6NANDDP:
1.236 + INFO_PRINTF1(_L("Hardware configuration: H6 NAND DP"));
1.237 + break;
1.238 +
1.239 + case EPlatformWINSCW:
1.240 + INFO_PRINTF1(_L("Hardware configuration: WINSCW"));
1.241 + break;
1.242 +
1.243 + default:
1.244 + SetTestStepResult(EFail);
1.245 + INFO_PRINTF1(_L("***Unrecognized platform!***"));
1.246 + break;
1.247 + }
1.248 +
1.249 + // get all the timer results from the server
1.250 + RStartupStateTimerResults timerResults;
1.251 + timerResults.GetAllTimerResults();
1.252 +
1.253 + // Get ecom start time and state. The state is a test state and should be -1
1.254 + TInt idx = timerResults.FindInOrderTimerResult(-1);
1.255 + if(idx == KErrNotFound)
1.256 + {
1.257 + INFO_PRINTF1(_L("Something went wrong......whoops\n"));
1.258 + SetTestStepResult(EFail);
1.259 + return TestStepResult();
1.260 + }
1.261 +
1.262 + TStartupStateTimerResult timerResult = timerResults.At(idx);
1.263 + TReal ecomStartTime = timerResult.iStartTime;
1.264 + TReal ecomComplTime = timerResult.iEndTime;
1.265 + TReal stateStartTime = 0.0;
1.266 + TReal stateComplTime = 0.0;
1.267 + TReal accumulatedTime = 0.0;
1.268 + TReal initialisationTime = 0.0;
1.269 +
1.270 + //Test for Critical Static state
1.271 + INFO_PRINTF1(_L("Critical Static"));
1.272 + TVerdict result = ProcessState(timerResults, EStartupStateCriticalStatic, stateStartTime, stateComplTime);
1.273 + if(result != EPass && result != EIgnore)
1.274 + {
1.275 + return TestStepResult();
1.276 + }
1.277 + accumulatedTime += (stateComplTime - stateStartTime);
1.278 + CheckPerformance(stateComplTime - stateStartTime, CriticalStaticLimit, _L("Critical static state"));
1.279 +
1.280 + //Test for initialisation
1.281 + initialisationTime = ecomComplTime - ecomStartTime - accumulatedTime;
1.282 + INFO_PRINTF2(_L("Initialisation Elapsed: %f mSecs\n"), ecomComplTime - ecomStartTime);
1.283 + accumulatedTime += initialisationTime;
1.284 + CheckPerformance(initialisationTime, InitialisationLimit, _L("Initialisation Time"));
1.285 +
1.286 + //Test for Critical Dynamic state
1.287 + result = ProcessState(timerResults, EStartupStateCriticalDynamic, stateStartTime, stateComplTime);
1.288 + if(result != EPass && result != EIgnore)
1.289 + {
1.290 + return TestStepResult();
1.291 + }
1.292 + accumulatedTime += (stateComplTime - stateStartTime);
1.293 + CheckPerformance(stateComplTime - stateStartTime, CriticalDynamicLimit, _L("Critical dynamic state"));
1.294 +
1.295 + //Test for Non Critical state
1.296 + result = ProcessState(timerResults, EStartupStateNonCritical, stateStartTime, stateComplTime);
1.297 + if(result != EPass && result != EIgnore)
1.298 + {
1.299 + return TestStepResult();
1.300 + }
1.301 + accumulatedTime += (stateComplTime - stateStartTime);
1.302 + CheckPerformance(stateComplTime - stateStartTime, NonCriticalLimit, _L("Non critical state"));
1.303 +
1.304 + //Test for overall time
1.305 + INFO_PRINTF2(_L("Ecom Stop Time: %f mSecs\n"), stateComplTime);
1.306 + INFO_PRINTF2(_L("Total Elapsed Time: %f mSecs\n"), stateComplTime - ecomStartTime);
1.307 + INFO_PRINTF2(_L("Total Accumulated Time: %f mSecs\n"), accumulatedTime);
1.308 + // CheckPerformance(accumulatedTime, 1000); Test unecessary as individual times that make up accumulated are already tested
1.309 +
1.310 + // Now get all the heap results from the server
1.311 + REComHeapUsageRecords heapResults;
1.312 + heapResults.OpenL();
1.313 +
1.314 + //Test for Critical Static state
1.315 + TInt CSUsage=0;
1.316 + INFO_PRINTF1(_L("Critical Static state"));
1.317 + result=ProcessState(heapResults,EStartupStateCriticalStatic,CSUsage);
1.318 + if(result != EPass && result != EIgnore)
1.319 + {
1.320 + return TestStepResult();
1.321 + }
1.322 + //Test for initialisation
1.323 + INFO_PRINTF1(_L("Initialisation state(including Critical Static measurement)"));
1.324 + TInt heapUsage=0;
1.325 + result=ProcessState(heapResults,-1,heapUsage);
1.326 + TInt initialisationHeapUsage=heapUsage-CSUsage;
1.327 + if(result != EPass && result != EIgnore)
1.328 + {
1.329 + return TestStepResult();
1.330 + }
1.331 + INFO_PRINTF1(_L("Initialisation state(excluding Critical Static measurement)"));
1.332 + INFO_PRINTF3(_L("State: %d heap usage: %d bytes\n"), -1,initialisationHeapUsage);
1.333 +
1.334 + //Test for Critical Dynamic state
1.335 + INFO_PRINTF1(_L("Critical Dynamic state"));
1.336 + result=ProcessState(heapResults,EStartupStateCriticalDynamic,heapUsage);
1.337 + if(result != EPass && result != EIgnore)
1.338 + {
1.339 + return TestStepResult();
1.340 + }
1.341 +
1.342 + //Test for Non Critical State
1.343 + INFO_PRINTF1(_L("Non Critical sate"));
1.344 + result=ProcessState(heapResults,EStartupStateNonCritical,heapUsage);
1.345 + if(result != EPass && result != EIgnore)
1.346 + {
1.347 + return TestStepResult();
1.348 + }
1.349 +
1.350 + heapResults.Close();
1.351 +#else
1.352 + MacroNotDefinedError();
1.353 +#endif // __ECOM_SERVER_PERFORMANCE__
1.354 + return TestStepResult();
1.355 + }