os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComClientRequestPerfTestStep.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/Te_EComClientRequestPerfTestStep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,661 @@
     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_EComClientRequrestPerfTestStep.cpp
    1.18 +// Tests the performance of ECom client calls
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @internalComponent
    1.25 +*/
    1.26 +
    1.27 +#include "Te_EComClientRequestPerfTestStep.h"
    1.28 +#include <ecom/ecom.h>
    1.29 +#include "Interface.h"
    1.30 +#include "EComSessionAux.h"
    1.31 +#include "EcomTestUtils.h"
    1.32 +#include <cs_subconparams.h>
    1.33 +#include "EComPerfTestDllTwo.h"
    1.34 +
    1.35 +#ifdef __ECOM_SERVER_PERFORMANCE__
    1.36 +// Constants for list interface testing
    1.37 +// There should be a single implementation of this interface in EComPerfTestDllOne.dll
    1.38 +const TUid KUidListImplTestInterface = {0x10009DF3};
    1.39 +// The resolver implementation uid in EComClientRequestPerfTestResolver.dll
    1.40 +const TUid KCustomResolverImplementationUid = {0x10009DF8};
    1.41 +// Constants for create implementation testing
    1.42 +// these are implementations from EComPerfTestDllTwo.dll
    1.43 +const TUid KUidCreateImplementation = {0x10009DF6};
    1.44 +// There should be a single implementation of this interface in EComPerfTestDllTwo.dll
    1.45 +const TUid KUidCreateImplTestInterface = {0x10009DF4};
    1.46 +// Constants for GetExtendedInterface and ListExtendedInterface testing
    1.47 +// these are implementations from EComExample10.dll
    1.48 +const TUid KExample10ImplementationUid = {0x10009E38};
    1.49 +const TUid KExample10ImplementationUid2 = {0x10009E3A};
    1.50 +// Expected data type
    1.51 +_LIT8(KExpectedDataTypeDllOne,"ECom_Performance1");
    1.52 +_LIT8(KExpectedDataTypeDllTwo,"ECom_Performance2-1");
    1.53 +_LIT8(KExpectedDataTypeExample10, "Example 10");
    1.54 +// Extended Interfaces
    1.55 +const TUid KExtendedInterfaceUid1 = {0x10009E44};
    1.56 +const TUid KExtendedInterfaceUid2 = {0x10009E45};
    1.57 +const TUid KExtendedInterfaceUid3 = {0x10009E46};
    1.58 +// Uids for list implementation and create implementation test with extended interfaces. 
    1.59 +const TUid KExample10InterfaceUid = {0x10009DBB}; 
    1.60 +
    1.61 +// Start-up urel/armv5 test limits for H2 RAM(non-NAND) hardware configuration. These figures were determined using benchmarks from the ONB&TR.
    1.62 +// Although these limits are passed to CheckPerformance() for non urel/armv5 testing this method
    1.63 +// does not test against them. It is disabled.
    1.64 +// The following constants are test limit allowances that are used for each client request test. The limit
    1.65 +// for each test is determined by adding together these limits as appropriate.
    1.66 +// We do not provide special set of constants for H2 NAND cofiguration because H2 NAND tests are not performed.
    1.67 +const TReal KBasicH2RAM = 5;
    1.68 +const TReal KSecurityInfoRetrievedH2RAM = 5;
    1.69 +const TReal KDefaultResolverH2RAM = 2;
    1.70 +const TReal KCustomResolverH2RAM = 5;
    1.71 +const TReal KDllLoadedH2RAM = 3;
    1.72 +const TReal KFetchExtendedInterfaceH2RAM = 1; 
    1.73 +const TReal KListExtendedInterfacesH2RAM = 1;
    1.74 +const TReal KExtendedInterfacesMatchedH2RAM = 2; 
    1.75 +// Start-up urel/armv5 test limits for H4 RAM(non-NAND) hardware configuration. These constants were determined using benchmarks from the ONB&TR.
    1.76 +const TReal KBasicH4RAM = 2;
    1.77 +const TReal KSecurityInfoRetrievedH4RAM = 3;
    1.78 +const TReal KDefaultResolverH4RAM = 1;
    1.79 +const TReal KCustomResolverH4RAM = 3;
    1.80 +const TReal KDllLoadedH4RAM = 2;
    1.81 +const TReal KFetchExtendedInterfaceH4RAM = 1; 
    1.82 +const TReal KListExtendedInterfacesH4RAM = 1; 
    1.83 +const TReal KExtendedInterfacesMatchedH4RAM = 1; 
    1.84 +// Start-up urel/armv5 test limits for H4 NAND ROM configuration. These constants were determined using benchmarks from the ONB&TR.
    1.85 +const TReal KBasicH4NAND = 3;
    1.86 +const TReal KSecurityInfoRetrievedH4NAND = 9;
    1.87 +const TReal KDefaultResolverH4NAND = 2;
    1.88 +const TReal KCustomResolverH4NAND = 8;
    1.89 +const TReal KDllLoadedH4NAND = 7;
    1.90 +const TReal KFetchExtendedInterfaceH4NAND = 1; 
    1.91 +const TReal KListExtendedInterfacesH4NAND = 1; 
    1.92 +const TReal KExtendedInterfacesMatchedH4NAND = 2; 
    1.93 +// Start-up urel/armv5 test limits for H6 RAM(non-NAND) hardware configuration. These constants were determined using benchmarks from the ONB&TR.
    1.94 +const TReal KBasicH6RAM = 1;
    1.95 +const TReal KSecurityInfoRetrievedH6RAM = 1.5;
    1.96 +const TReal KDefaultResolverH6RAM = 1;
    1.97 +const TReal KCustomResolverH6RAM = 1.5;
    1.98 +const TReal KDllLoadedH6RAM = 1;
    1.99 +const TReal KFetchExtendedInterfaceH6RAM = 1; 
   1.100 +const TReal KListExtendedInterfacesH6RAM = 1; 
   1.101 +const TReal KExtendedInterfacesMatchedH6RAM = 1; 
   1.102 +// Start-up urel/armv5 test limits for H6 NAND ROM configuration. These constants were determined using benchmarks from the ONB&TR.
   1.103 +const TReal KBasicH6NAND = 1.5;
   1.104 +const TReal KSecurityInfoRetrievedH6NAND = 4;
   1.105 +const TReal KDefaultResolverH6NAND = 1;
   1.106 +const TReal KCustomResolverH6NAND = 4;
   1.107 +const TReal KDllLoadedH6NAND = 3;
   1.108 +const TReal KFetchExtendedInterfaceH6NAND = 1; 
   1.109 +const TReal KListExtendedInterfacesH6NAND = 1; 
   1.110 +const TReal KExtendedInterfacesMatchedH6NAND = 1; 
   1.111 +//Specify the number of iterations to do to obtain the average value for API time measurement
   1.112 +const TInt KNumberIteration=10;
   1.113 +#endif // __ECOM_SERVER_PERFORMANCE__
   1.114 +
   1.115 +CEComClientRequestsPerfTest::CEComClientRequestsPerfTest() : CEComPerfTestBase(KEComClientRequestsPerfTest)
   1.116 +	{
   1.117 +	}
   1.118 +
   1.119 +CEComClientRequestsPerfTest::~CEComClientRequestsPerfTest()
   1.120 +	{
   1.121 +	}
   1.122 +
   1.123 +#ifdef __ECOM_SERVER_PERFORMANCE__
   1.124 +void CEComClientRequestsPerfTest::WaitForDllUnload()
   1.125 +	{
   1.126 +#if defined(__EPOC32__) && !defined(_DEBUG)
   1.127 +	// Timeout to unload dll when lazy unload is enabled - which it is by default
   1.128 +	// Used only for HW release builds
   1.129 +	const TInt32 KLazyUnloadTimeout = 150000000; // 2.5 minutes
   1.130 +
   1.131 +	// Wait for DLL to unload - target release builds only
   1.132 +	User::After(KLazyUnloadTimeout);
   1.133 +#else
   1.134 +	INFO_PRINTF1(_L("*** WARNING: Use results with care no delay for DLL to unload ***\n"));
   1.135 +#endif // #if defined(__EPOC32__) && !defined(_DEBUG)
   1.136 +
   1.137 +	}
   1.138 +#endif // __ECOM_SERVER_PERFORMANCE__
   1.139 +
   1.140 +/*
   1.141 + Test cases covered in the test step:
   1.142 + 
   1.143 + 1. Time calls to ListImplementationsL and CreateImplementationL without resolver, with default resolver and 
   1.144 + with custom resolver under various conditions.
   1.145 + 	1.1 ListImplementationL performance testing without extended interfaces.
   1.146 + 	1.2 CreateImplementationL performance testing without extended interfaces.
   1.147 + 	1.3 ListImplementationL performance testing with extended interfaces.(TestCaseID:SYSLIB-ECOM-CT-3598)
   1.148 + 	1.4 CreateImplementationL performance testing with extended interfaces.(TestCaseID:SYSLIB-ECOM-CT-3599)
   1.149 + 
   1.150 + 2. Time calls to GetExtendedInterfaceL and ListExtendedInterfacesL under various conditions.
   1.151 + 	2.1 ListExtendedInterfacesL performance testing.(TestCaseID:SYSLIB-ECOM-CT-3600)
   1.152 + 	2.2 GetExtendedInterfaceL performance testing.(TestCaseID: SYSLIB-ECOM-CT-3601)
   1.153 +
   1.154 + 1.3,1.4,2.1 and 2.2 are test cases for EC43
   1.155 + @return EPass if the test completed successfully and the performance of the client calls are within the maximum
   1.156 +*/
   1.157 +TVerdict CEComClientRequestsPerfTest::doTestStepL()
   1.158 +	{
   1.159 +#ifdef __ECOM_SERVER_PERFORMANCE__
   1.160 +	RImplInfoPtrArray ifArray;
   1.161 +	RArray<TUid> extendedInterfaces;
   1.162 +	CleanupClosePushL(extendedInterfaces);
   1.163 +	extendedInterfaces.AppendL(KExtendedInterfaceUid1);
   1.164 +	extendedInterfaces.AppendL(KExtendedInterfaceUid2);
   1.165 +	extendedInterfaces.AppendL(KExtendedInterfaceUid3);
   1.166 +	//set configuration-dependent timing limits (for non-NAND and NAND ROM configurations)
   1.167 +	TReal limitBasic = 0;
   1.168 +	TReal limitSecurityInfoRetrieved = 0;
   1.169 +	TReal limitDefaultResolver = 0;
   1.170 +	TReal limitCustomResolver = 0;
   1.171 +	TReal limitDllLoaded = 0;
   1.172 +	TReal limitFetchExtendedInterface = 0;
   1.173 +	TReal limitListExtendedInterfaces = 0;
   1.174 +	TReal limitExtendedInterfaceMatched = 0;
   1.175 +	
   1.176 +	THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration();
   1.177 +	switch (hardware_configuration)
   1.178 +		{
   1.179 +		case EPlatformH2RAM:
   1.180 +	    	limitBasic = KBasicH2RAM;
   1.181 +			limitSecurityInfoRetrieved = KSecurityInfoRetrievedH2RAM;
   1.182 +			limitDefaultResolver = KDefaultResolverH2RAM;
   1.183 +			limitCustomResolver = KCustomResolverH2RAM;
   1.184 +			limitDllLoaded = KDllLoadedH2RAM;
   1.185 +			limitFetchExtendedInterface = KFetchExtendedInterfaceH2RAM;
   1.186 +			limitListExtendedInterfaces = KListExtendedInterfacesH2RAM;
   1.187 +			limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH2RAM;
   1.188 +			INFO_PRINTF1(_L("Hardware configuration: H2 RAM"));
   1.189 +			break;
   1.190 +			
   1.191 +		case EPlatformH2NAND:
   1.192 +			INFO_PRINTF1(_L("Hardware configuration: H2 NAND"));
   1.193 +			INFO_PRINTF1(_L("***Performance testing on H2 NAND is not supported!***"));
   1.194 +			SetTestStepResult(EFail);			
   1.195 +			break;
   1.196 +			
   1.197 +		case EPlatformH2NANDDP:
   1.198 +			INFO_PRINTF1(_L("Hardware configuration: H2 NAND DP"));
   1.199 +			INFO_PRINTF1(_L("***Performance testing on H2 NAND DP is not supported!***"));
   1.200 +			SetTestStepResult(EFail);			
   1.201 +			break;
   1.202 +		
   1.203 +		case EPlatformH4RAM:
   1.204 +			limitBasic = KBasicH4RAM;
   1.205 +			limitSecurityInfoRetrieved = KSecurityInfoRetrievedH4RAM;
   1.206 +			limitDefaultResolver = KDefaultResolverH4RAM;
   1.207 +			limitCustomResolver = KCustomResolverH4RAM;
   1.208 +			limitDllLoaded = KDllLoadedH4RAM;
   1.209 +			limitFetchExtendedInterface = KFetchExtendedInterfaceH4RAM;
   1.210 +			limitListExtendedInterfaces = KListExtendedInterfacesH4RAM;
   1.211 +			limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH4RAM;
   1.212 +			INFO_PRINTF1(_L("Hardware configuration: H4 RAM"));
   1.213 +			break;
   1.214 +		
   1.215 +		case EPlatformH4NAND:		
   1.216 +			limitBasic = KBasicH4NAND;
   1.217 +			limitSecurityInfoRetrieved = KSecurityInfoRetrievedH4NAND;
   1.218 +			limitDefaultResolver = KDefaultResolverH4NAND;
   1.219 +			limitCustomResolver = KCustomResolverH4NAND;
   1.220 +			limitDllLoaded = KDllLoadedH4NAND;
   1.221 +			limitFetchExtendedInterface = KFetchExtendedInterfaceH4NAND;
   1.222 +			limitListExtendedInterfaces = KListExtendedInterfacesH4NAND;
   1.223 +			limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH4NAND;			
   1.224 +			INFO_PRINTF1(_L("Hardware configuration: H4 NAND"));			
   1.225 +			break;
   1.226 +		
   1.227 +		case EPlatformH4NANDDP:	
   1.228 +			INFO_PRINTF1(_L("Hardware configuration: H4 NAND DP"));
   1.229 +			break;
   1.230 +			
   1.231 +		case EPlatformH6RAM:
   1.232 +			limitBasic = KBasicH6RAM;
   1.233 +			limitSecurityInfoRetrieved = KSecurityInfoRetrievedH6RAM;
   1.234 +			limitDefaultResolver = KDefaultResolverH6RAM;
   1.235 +			limitCustomResolver = KCustomResolverH6RAM;
   1.236 +			limitDllLoaded = KDllLoadedH6RAM;
   1.237 +			limitFetchExtendedInterface = KFetchExtendedInterfaceH6RAM;
   1.238 +			limitListExtendedInterfaces = KListExtendedInterfacesH6RAM;
   1.239 +			limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH6RAM;
   1.240 +			INFO_PRINTF1(_L("Hardware configuration: H6 RAM"));
   1.241 +			break;
   1.242 +		
   1.243 +		case EPlatformH6NAND:		
   1.244 +			limitBasic = KBasicH6NAND;
   1.245 +			limitSecurityInfoRetrieved = KSecurityInfoRetrievedH6NAND;
   1.246 +			limitDefaultResolver = KDefaultResolverH6NAND;
   1.247 +			limitCustomResolver = KCustomResolverH6NAND;
   1.248 +			limitDllLoaded = KDllLoadedH6NAND;
   1.249 +			limitFetchExtendedInterface = KFetchExtendedInterfaceH6NAND;
   1.250 +			limitListExtendedInterfaces = KListExtendedInterfacesH6NAND;
   1.251 +			limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH6NAND;			
   1.252 +			INFO_PRINTF1(_L("Hardware configuration: H6 NAND"));			
   1.253 +			break;
   1.254 +		case EPlatformH6NANDDP:	
   1.255 +			INFO_PRINTF1(_L("Hardware configuration: H6 NAND DP"));
   1.256 +			break;
   1.257 +		
   1.258 +		case EPlatformWINSCW:
   1.259 +			INFO_PRINTF1(_L("Hardware configuration: WINSCW"));
   1.260 +			break;
   1.261 +		
   1.262 +		default:
   1.263 +			INFO_PRINTF1(_L("***Unrecognized platform!***"));
   1.264 +			SetTestStepResult(EFail);
   1.265 +			break;		
   1.266 +		}
   1.267 +
   1.268 +	//
   1.269 +	// 1.1 ListImplementationL performance testing without extended interfaces.
   1.270 +	//
   1.271 +	TInt totalTime=0;
   1.272 +	INFO_PRINTF1(_L("Time servicing ListImplementationsL requests - each request returns 4 implementations:\n"));
   1.273 +	//
   1.274 +	// Time ListImplementationsL without resolver
   1.275 +	//
   1.276 +	TInt startTime = User::FastCounter();
   1.277 +	REComSession::ListImplementationsL(KUidListImplTestInterface, ifArray);
   1.278 +	TInt endTime = User::FastCounter();
   1.279 +	TEST(ifArray.Count()==4);
   1.280 +	ifArray.ResetAndDestroy();
   1.281 +	TReal netTime = FastCountToMilliseconds(endTime-startTime);
   1.282 +	CheckPerformance(netTime, limitBasic+limitSecurityInfoRetrieved, _L("Call with: no resolver, security info retrieval"));
   1.283 +
   1.284 +	//
   1.285 +	// Average Time over KNumberIteration ListImplementationsL without resolver when the DLL security info is cached
   1.286 +	//
   1.287 +	totalTime=0;
   1.288 +	for (TInt i=0;i<KNumberIteration;i++)
   1.289 +		{
   1.290 +		startTime = User::FastCounter();
   1.291 +		REComSession::ListImplementationsL(KUidListImplTestInterface, ifArray);
   1.292 +		endTime = User::FastCounter();
   1.293 +		TEST(ifArray.Count()==4);
   1.294 +		ifArray.ResetAndDestroy();
   1.295 +		totalTime+=(endTime-startTime);
   1.296 +		}
   1.297 +		netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.298 +		CheckPerformance(netTime, limitBasic, _L("Call with: no resolver, security info cached"));
   1.299 +
   1.300 +	//
   1.301 +	// Average Time over KNumberIteration ListImplementationsL with default resolver when the DLL security info is cached
   1.302 +	//
   1.303 +	totalTime=0;
   1.304 +	TEComResolverParams params;
   1.305 +	params.SetDataType(KExpectedDataTypeDllOne());
   1.306 +	params.SetGenericMatch(ETrue);
   1.307 +	for (TInt i=0;i<KNumberIteration;i++)	
   1.308 +		{	
   1.309 +		startTime = User::FastCounter();
   1.310 +		REComSession::ListImplementationsL(KUidListImplTestInterface, params, ifArray);
   1.311 +		endTime = User::FastCounter();
   1.312 +		TEST(ifArray.Count()==4);
   1.313 +		ifArray.ResetAndDestroy();
   1.314 +		totalTime+=(endTime-startTime);	
   1.315 +		}
   1.316 +		netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.317 +		CheckPerformance(netTime, limitBasic+limitDefaultResolver, _L("Call with: default resolver, security info cached"));
   1.318 +
   1.319 +	//
   1.320 +	// Average Time over KNumberIteration ListImplementationsL with custom resolver when the DLL security check is cached
   1.321 +	//
   1.322 +	totalTime=0;
   1.323 +	for (TInt i=0;i<KNumberIteration;i++)	
   1.324 +		{	
   1.325 +		startTime = User::FastCounter();
   1.326 +		REComSession::ListImplementationsL(KUidListImplTestInterface, params, KCustomResolverImplementationUid, ifArray);
   1.327 +		endTime = User::FastCounter();
   1.328 +		TEST(ifArray.Count()==4);
   1.329 +		ifArray.ResetAndDestroy();
   1.330 +		totalTime+=(endTime-startTime);
   1.331 +		}
   1.332 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.333 +	CheckPerformance(netTime, limitBasic+limitCustomResolver, _L("Call with: custom resolver, security info cached"));
   1.334 +
   1.335 +	//
   1.336 +	// 1.2 CreateImplementationL performance testing without extended interfaces.
   1.337 +	//
   1.338 +	INFO_PRINTF1(_L("Time servicing CreateImplementationL requests:\n"));
   1.339 +	//
   1.340 +	// Time Create Implementation without resolver with retrieval of security info and dll will be loaded
   1.341 +	//
   1.342 +	TUid ecomDestructorId;
   1.343 +	startTime = User::FastCounter();
   1.344 +	CImplementationClassExampleTwo *ecomPtr = (CImplementationClassExampleTwo*)REComSession::CreateImplementationL(KUidCreateImplementation, ecomDestructorId);
   1.345 +	endTime = User::FastCounter();
   1.346 +	REComSession::DestroyedImplementation(ecomDestructorId);
   1.347 +	delete ecomPtr;
   1.348 +	netTime = FastCountToMilliseconds(endTime-startTime);
   1.349 +	CheckPerformance(netTime, limitBasic+limitDllLoaded+limitSecurityInfoRetrieved, _L("Call with: no resolver, dll to be loaded, security info retrieval"));
   1.350 +	REComSession::FinalClose();
   1.351 +
   1.352 +	WaitForDllUnload();
   1.353 +
   1.354 +	//
   1.355 +	// Time CreateImplementation without resolver when the DLL security info cached and dll will be loaded
   1.356 +	//
   1.357 +	startTime = User::FastCounter();
   1.358 +	ecomPtr = (CImplementationClassExampleTwo*)REComSession::CreateImplementationL(KUidCreateImplementation, ecomDestructorId);
   1.359 +	endTime = User::FastCounter();
   1.360 +	netTime = FastCountToMilliseconds(endTime-startTime);
   1.361 +	CheckPerformance(netTime, limitBasic+limitDllLoaded, _L("Call with: no resolver, dll to be loaded, security info cached"));
   1.362 +
   1.363 +	//
   1.364 +	// Average Time over KNumberIteration CreateImplementation without resolver when the DLL security info is cached and dll is already
   1.365 +	// loaded
   1.366 +	//
   1.367 +	totalTime=0;
   1.368 +	CImplementationClassExampleTwo *ecomPtr2=NULL;
   1.369 +	TUid ecomDestructorId2;
   1.370 +	for (TInt i=0;i<KNumberIteration;i++)	
   1.371 +		{	
   1.372 +		startTime = User::FastCounter();
   1.373 +		ecomPtr2 = (CImplementationClassExampleTwo*)REComSession::CreateImplementationL(KUidCreateImplementation, ecomDestructorId2);
   1.374 +		endTime = User::FastCounter();
   1.375 +		totalTime+=endTime-startTime;
   1.376 +		REComSession::DestroyedImplementation(ecomDestructorId2);
   1.377 +		delete ecomPtr2;
   1.378 +		}
   1.379 +	REComSession::DestroyedImplementation(ecomDestructorId);
   1.380 +	delete ecomPtr;
   1.381 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.382 +	CheckPerformance(netTime, limitBasic, _L("Call with: no resolver, dll already loaded, security info cached"));
   1.383 +	REComSession::FinalClose();
   1.384 +
   1.385 +	WaitForDllUnload();
   1.386 +
   1.387 +	//
   1.388 +	// Time CreateImplementation with default resolver when the DLL security info cached and dll must be loaded
   1.389 +	//
   1.390 +	params.SetDataType(KExpectedDataTypeDllTwo);
   1.391 +	startTime = User::FastCounter();
   1.392 +	ecomPtr = (CImplementationClassExampleTwo*)REComSession::CreateImplementationL(KUidCreateImplTestInterface, ecomDestructorId, params);
   1.393 +	endTime = User::FastCounter();
   1.394 +	netTime = FastCountToMilliseconds(endTime-startTime);
   1.395 +	CheckPerformance(netTime, limitBasic+limitDefaultResolver+limitDllLoaded, _L("Call with: default resolver, dll to be loaded, security info cached"));
   1.396 +
   1.397 +	//
   1.398 +	// Average Time over KNumberIteration CreateImplementation with default resolver when the DLL security info is cached and dll is already
   1.399 +	// loaded
   1.400 +	//
   1.401 +	totalTime=0;
   1.402 +	for (TInt i=0;i<KNumberIteration;i++)	
   1.403 +		{
   1.404 +		startTime = User::FastCounter();
   1.405 +		ecomPtr2 = (CImplementationClassExampleTwo*)REComSession::CreateImplementationL(KUidCreateImplTestInterface, ecomDestructorId2, params);
   1.406 +		endTime = User::FastCounter();
   1.407 +		totalTime+=endTime-startTime;
   1.408 +		REComSession::DestroyedImplementation(ecomDestructorId2);
   1.409 +		delete ecomPtr2;
   1.410 +		}
   1.411 +	REComSession::DestroyedImplementation(ecomDestructorId);
   1.412 +	delete ecomPtr;	
   1.413 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.414 +	CheckPerformance(netTime, limitBasic+limitDefaultResolver, _L("Call with: default resolver, dll already loaded, security info cached"));
   1.415 +	REComSession::FinalClose();
   1.416 +
   1.417 +	WaitForDllUnload();
   1.418 +
   1.419 +	//
   1.420 +	// Time CreateImplementation with custom resolver when the DLL security info cached and dll must be loaded
   1.421 +	//
   1.422 +	startTime = User::FastCounter();
   1.423 +	ecomPtr = (CImplementationClassExampleTwo*)REComSession::CreateImplementationL(
   1.424 +				KUidCreateImplTestInterface, ecomDestructorId, params, KCustomResolverImplementationUid);
   1.425 +	endTime = User::FastCounter();
   1.426 +	netTime = FastCountToMilliseconds(endTime-startTime);
   1.427 +	CheckPerformance(netTime, limitBasic+limitCustomResolver+limitDllLoaded, _L("Call with: custom resolver, dll to be loaded, security info cached"));
   1.428 +
   1.429 +	//
   1.430 +	// Average Time over KNumberIteration CreateImplementation with default resolver when the DLL security info is cached and dll is already
   1.431 +	// loaded
   1.432 +	//
   1.433 +	totalTime=0;
   1.434 +	for (TInt i=0;i<KNumberIteration;i++)	
   1.435 +		{	
   1.436 +		startTime = User::FastCounter();
   1.437 +		ecomPtr2 = (CImplementationClassExampleTwo*)REComSession::CreateImplementationL(
   1.438 +					KUidCreateImplTestInterface, ecomDestructorId2, params, KCustomResolverImplementationUid);
   1.439 +		endTime = User::FastCounter();
   1.440 +		totalTime+=endTime-startTime;	
   1.441 +		REComSession::DestroyedImplementation(ecomDestructorId2);
   1.442 +		delete ecomPtr2;
   1.443 +		}
   1.444 +	REComSession::DestroyedImplementation(ecomDestructorId);
   1.445 +	delete ecomPtr;	
   1.446 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.447 +	CheckPerformance(netTime, limitBasic+limitCustomResolver, _L("Call with: custom resolver, dll already loaded, security info cached"));
   1.448 +
   1.449 +	//
   1.450 +	// 1.3 ListImplementationL performance testing with extended interfaces.
   1.451 +	//
   1.452 +	totalTime = 0;
   1.453 +	INFO_PRINTF1(_L("Time servicing ListImplementationsL with extended interfaces requests:\n"));
   1.454 +	//
   1.455 +	// Time ListImplementationsL with extended interfaces without resolver
   1.456 +	//
   1.457 +	startTime = User::FastCounter();
   1.458 +	REComSession::ListImplementationsL(KExample10InterfaceUid, extendedInterfaces, ifArray);
   1.459 +	endTime = User::FastCounter();
   1.460 +	TEST(ifArray.Count() == 1);
   1.461 +	ifArray.ResetAndDestroy();
   1.462 +	netTime = FastCountToMilliseconds(endTime-startTime);
   1.463 +	CheckPerformance(netTime, limitBasic+limitSecurityInfoRetrieved+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, no resolver, security info retrieval"));
   1.464 +
   1.465 +	//
   1.466 +	// Average Time over KNumberIteration ListImplementationsL with extended interfaces,without resolver when the DLL security info is cached
   1.467 +	//
   1.468 +	totalTime=0;
   1.469 +	for (TInt i = 0; i < KNumberIteration; i++)
   1.470 +		{
   1.471 +		startTime = User::FastCounter();
   1.472 +		REComSession::ListImplementationsL(KExample10InterfaceUid, extendedInterfaces, ifArray);
   1.473 +		endTime = User::FastCounter();
   1.474 +		TEST(ifArray.Count() == 1);
   1.475 +		ifArray.ResetAndDestroy();
   1.476 +		totalTime += (endTime-startTime);
   1.477 +		}
   1.478 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.479 +	CheckPerformance(netTime, limitBasic+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, no resolver, security info cached"));
   1.480 +
   1.481 +	//
   1.482 +	// Average Time over KNumberIteration ListImplementationsL with extended interfaces, with default resolver when the DLL security info is cached
   1.483 +	//
   1.484 +	totalTime = 0;
   1.485 +	params.SetDataType(KExpectedDataTypeExample10());
   1.486 +	params.SetGenericMatch(ETrue);
   1.487 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.488 +		{	
   1.489 +		startTime = User::FastCounter();
   1.490 +		REComSession::ListImplementationsL(KExample10InterfaceUid, extendedInterfaces, params, ifArray);
   1.491 +		endTime = User::FastCounter();
   1.492 +		TEST(ifArray.Count() == 1);
   1.493 +		ifArray.ResetAndDestroy();
   1.494 +		totalTime += (endTime-startTime);	
   1.495 +		}
   1.496 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.497 +	CheckPerformance(netTime, limitBasic+limitDefaultResolver+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, default resolver, security info cached"));
   1.498 +
   1.499 +	//
   1.500 +	// Average Time over KNumberIteration ListImplementationsL with extended interfaces, with custom resolver when the DLL security check is cached
   1.501 +	//
   1.502 +	totalTime = 0;
   1.503 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.504 +		{	
   1.505 +		startTime = User::FastCounter();
   1.506 +		REComSession::ListImplementationsL(KExample10InterfaceUid, extendedInterfaces, params, KCustomResolverImplementationUid, ifArray);
   1.507 +		endTime = User::FastCounter();
   1.508 +		TEST(ifArray.Count() == 1);
   1.509 +		ifArray.ResetAndDestroy();
   1.510 +		totalTime += (endTime-startTime);
   1.511 +		}
   1.512 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.513 +	CheckPerformance(netTime, limitBasic+limitCustomResolver+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, custom resolver, security info cached"));
   1.514 +	
   1.515 +	//
   1.516 +	// 1.4 CreateImplementationL performance testing with extended interfaces.
   1.517 +	//
   1.518 +	CExampleInterface* dllPtr = NULL;
   1.519 +	CExampleInterface* dllPtr2 = NULL;
   1.520 +	totalTime = 0;
   1.521 +	INFO_PRINTF1(_L("Time servicing CreateImplementationsL with extended interfaces requests:\n"));
   1.522 +	//
   1.523 +	// Time CreateImplementation with extended interfaces, default resolver when the DLL security info cached and dll must be loaded
   1.524 +	//
   1.525 +	params.SetDataType(KExpectedDataTypeExample10);
   1.526 +	startTime = User::FastCounter();
   1.527 +	dllPtr = reinterpret_cast<CExampleInterface*>(REComSession::CreateImplementationL(KExample10InterfaceUid, extendedInterfaces, ecomDestructorId, params));
   1.528 +	endTime = User::FastCounter();
   1.529 +	netTime = FastCountToMilliseconds(endTime-startTime);
   1.530 +	CheckPerformance(netTime, limitBasic+limitDefaultResolver+limitDllLoaded+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, default resolver, dll to be loaded, security info cached"));
   1.531 +	
   1.532 +	//
   1.533 +	// Average Time over KNumberIteration CreateImplementation with extended interfaces, default resolver when the DLL security info is cached and dll is already
   1.534 +	// loaded
   1.535 +	//
   1.536 +	totalTime = 0;
   1.537 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.538 +		{
   1.539 +		startTime = User::FastCounter();
   1.540 +		dllPtr2 = reinterpret_cast<CExampleInterface*>(REComSession::CreateImplementationL(KExample10InterfaceUid, extendedInterfaces, ecomDestructorId2, params));
   1.541 +		endTime = User::FastCounter();
   1.542 +		totalTime += endTime-startTime;
   1.543 +		REComSession::DestroyedImplementation(ecomDestructorId2);
   1.544 +		delete dllPtr2;
   1.545 +		}
   1.546 +	REComSession::DestroyedImplementation(ecomDestructorId);
   1.547 +	delete dllPtr;	
   1.548 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.549 +	CheckPerformance(netTime, limitBasic+limitDefaultResolver+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, default resolver, dll already loaded, security info cached"));
   1.550 +	REComSession::FinalClose();
   1.551 +	WaitForDllUnload();
   1.552 +
   1.553 +	//
   1.554 +	// Time CreateImplementation with extended interfaces, custom resolver when the DLL security info cached and dll must be loaded
   1.555 +	//
   1.556 +	startTime = User::FastCounter();
   1.557 +	dllPtr = reinterpret_cast<CExampleInterface*>(REComSession::CreateImplementationL(
   1.558 +		KExample10InterfaceUid, extendedInterfaces, ecomDestructorId, params, KCustomResolverImplementationUid));
   1.559 +	endTime = User::FastCounter();
   1.560 +	netTime = FastCountToMilliseconds(endTime-startTime);
   1.561 +	CheckPerformance(netTime, limitBasic+limitCustomResolver+limitDllLoaded+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, custom resolver, dll to be loaded, security info cached"));
   1.562 +
   1.563 +	//
   1.564 +	// Average Time over KNumberIteration CreateImplementation with extended interfaces, custom resolver when the DLL security info is cached and dll is already
   1.565 +	// loaded
   1.566 +	//
   1.567 +	totalTime = 0;
   1.568 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.569 +		{	
   1.570 +		startTime = User::FastCounter();
   1.571 +		dllPtr2 = reinterpret_cast<CExampleInterface*>(REComSession::CreateImplementationL(
   1.572 +			KExample10InterfaceUid, extendedInterfaces, ecomDestructorId2, params, KCustomResolverImplementationUid));
   1.573 +		endTime = User::FastCounter();
   1.574 +		totalTime += endTime-startTime;	
   1.575 +		REComSession::DestroyedImplementation(ecomDestructorId2);
   1.576 +		delete dllPtr2;
   1.577 +		}
   1.578 +	REComSession::DestroyedImplementation(ecomDestructorId);
   1.579 +	delete dllPtr;	
   1.580 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.581 +	CheckPerformance(netTime, limitBasic+limitCustomResolver+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, custom resolver, dll already loaded, security info cached"));
   1.582 +	
   1.583 +	REComSession::FinalClose();
   1.584 +	WaitForDllUnload();
   1.585 +	CleanupStack::PopAndDestroy(&extendedInterfaces);
   1.586 +
   1.587 +	//
   1.588 +	// 2.1 ListExtendedInterfacesL performance testing.
   1.589 +	//
   1.590 +	RArray<TUid> ifInfo;
   1.591 +	CleanupClosePushL(ifInfo);
   1.592 +	totalTime = 0;
   1.593 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.594 +		{
   1.595 +		startTime = User::FastCounter();
   1.596 +		REComSession::ListExtendedInterfacesL(KExample10ImplementationUid,ifInfo);
   1.597 +		endTime = User::FastCounter();
   1.598 +		// Ensure test is valid by testing return parameters
   1.599 +		TEST(ifInfo.Count() == 3);
   1.600 +		totalTime += endTime-startTime;
   1.601 +		ifInfo.Reset();
   1.602 +		}
   1.603 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.604 +	CheckPerformance(netTime, limitListExtendedInterfaces, _L("List extended interface. Three interfaces returned."));
   1.605 +		
   1.606 +	// Test with no interfaces returned
   1.607 +	totalTime = 0;
   1.608 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.609 +		{
   1.610 +		startTime = User::FastCounter();
   1.611 +		REComSession::ListExtendedInterfacesL(KExample10ImplementationUid2,ifInfo);
   1.612 +		endTime = User::FastCounter();
   1.613 +		// Ensure test is valid by testing return parameters
   1.614 +		TEST(ifInfo.Count() == 0);
   1.615 +		totalTime += endTime-startTime;
   1.616 +		ifInfo.Reset();
   1.617 +		}
   1.618 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.619 +	CheckPerformance(netTime, limitListExtendedInterfaces, _L("List extended interface. No interface returned."));
   1.620 +	CleanupStack::PopAndDestroy(&ifInfo);
   1.621 +
   1.622 +	//
   1.623 +	// 2.2 GetExtendedInterfaceL performance testing.
   1.624 +	//
   1.625 +	
   1.626 +	TUid instanceKey;
   1.627 +	// Set up some empty initialisation parameters
   1.628 +	CExampleInterface::TExampleInterfaceInitParams initParams;
   1.629 +	initParams.integer		= 0;
   1.630 +	initParams.descriptor	= NULL;
   1.631 +	dllPtr = REINTERPRET_CAST(CExampleInterface*, 
   1.632 +							REComSession::CreateImplementationL(KExample10ImplementationUid,
   1.633 +															   instanceKey,
   1.634 +															   &initParams));
   1.635 +	
   1.636 +	// Call extended interface here.
   1.637 +	totalTime = 0;
   1.638 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.639 +		{
   1.640 +		startTime = User::FastCounter();
   1.641 +		MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(REComSession::GetExtendedInterfaceL(instanceKey, KExtendedInterfaceUid1 ));
   1.642 +		endTime = User::FastCounter();
   1.643 +		totalTime += endTime - startTime;
   1.644 +		}
   1.645 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.646 +	CheckPerformance(netTime, limitFetchExtendedInterface, _L("Get extended interface. Interface is part of main instantiation object."));
   1.647 +	totalTime = 0;
   1.648 +	for (TInt i = 0; i < KNumberIteration; i++)	
   1.649 +		{
   1.650 +		startTime = User::FastCounter();
   1.651 +		MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(REComSession::GetExtendedInterfaceL(instanceKey, KExtendedInterfaceUid2 ));
   1.652 +		endTime = User::FastCounter();
   1.653 +		totalTime += endTime - startTime;
   1.654 +		}
   1.655 +	netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration;
   1.656 +	CheckPerformance(netTime, limitFetchExtendedInterface, _L("Get extended interface. Interface is separate object."));
   1.657 +	REComSession::DestroyedImplementation(instanceKey);
   1.658 +	delete dllPtr;
   1.659 +	REComSession::FinalClose();
   1.660 +#else
   1.661 +	MacroNotDefinedError();
   1.662 +#endif // __ECOM_SERVER_PERFORMANCE__
   1.663 +	return TestStepResult();
   1.664 +	}