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_EComClientRequrestPerfTestStep.cpp sl@0: // Tests the performance of ECom client calls sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include "Te_EComClientRequestPerfTestStep.h" sl@0: #include sl@0: #include "Interface.h" sl@0: #include "EComSessionAux.h" sl@0: #include "EcomTestUtils.h" sl@0: #include sl@0: #include "EComPerfTestDllTwo.h" sl@0: sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: // Constants for list interface testing sl@0: // There should be a single implementation of this interface in EComPerfTestDllOne.dll sl@0: const TUid KUidListImplTestInterface = {0x10009DF3}; sl@0: // The resolver implementation uid in EComClientRequestPerfTestResolver.dll sl@0: const TUid KCustomResolverImplementationUid = {0x10009DF8}; sl@0: // Constants for create implementation testing sl@0: // these are implementations from EComPerfTestDllTwo.dll sl@0: const TUid KUidCreateImplementation = {0x10009DF6}; sl@0: // There should be a single implementation of this interface in EComPerfTestDllTwo.dll sl@0: const TUid KUidCreateImplTestInterface = {0x10009DF4}; sl@0: // Constants for GetExtendedInterface and ListExtendedInterface testing sl@0: // these are implementations from EComExample10.dll sl@0: const TUid KExample10ImplementationUid = {0x10009E38}; sl@0: const TUid KExample10ImplementationUid2 = {0x10009E3A}; sl@0: // Expected data type sl@0: _LIT8(KExpectedDataTypeDllOne,"ECom_Performance1"); sl@0: _LIT8(KExpectedDataTypeDllTwo,"ECom_Performance2-1"); sl@0: _LIT8(KExpectedDataTypeExample10, "Example 10"); sl@0: // Extended Interfaces sl@0: const TUid KExtendedInterfaceUid1 = {0x10009E44}; sl@0: const TUid KExtendedInterfaceUid2 = {0x10009E45}; sl@0: const TUid KExtendedInterfaceUid3 = {0x10009E46}; sl@0: // Uids for list implementation and create implementation test with extended interfaces. sl@0: const TUid KExample10InterfaceUid = {0x10009DBB}; sl@0: sl@0: // Start-up urel/armv5 test limits for H2 RAM(non-NAND) hardware configuration. 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: // The following constants are test limit allowances that are used for each client request test. The limit sl@0: // for each test is determined by adding together these limits as appropriate. sl@0: // We do not provide special set of constants for H2 NAND cofiguration because H2 NAND tests are not performed. sl@0: const TReal KBasicH2RAM = 5; sl@0: const TReal KSecurityInfoRetrievedH2RAM = 5; sl@0: const TReal KDefaultResolverH2RAM = 2; sl@0: const TReal KCustomResolverH2RAM = 5; sl@0: const TReal KDllLoadedH2RAM = 3; sl@0: const TReal KFetchExtendedInterfaceH2RAM = 1; sl@0: const TReal KListExtendedInterfacesH2RAM = 1; sl@0: const TReal KExtendedInterfacesMatchedH2RAM = 2; sl@0: // Start-up urel/armv5 test limits for H4 RAM(non-NAND) hardware configuration. These constants were determined using benchmarks from the ONB&TR. sl@0: const TReal KBasicH4RAM = 2; sl@0: const TReal KSecurityInfoRetrievedH4RAM = 3; sl@0: const TReal KDefaultResolverH4RAM = 1; sl@0: const TReal KCustomResolverH4RAM = 3; sl@0: const TReal KDllLoadedH4RAM = 2; sl@0: const TReal KFetchExtendedInterfaceH4RAM = 1; sl@0: const TReal KListExtendedInterfacesH4RAM = 1; sl@0: const TReal KExtendedInterfacesMatchedH4RAM = 1; sl@0: // Start-up urel/armv5 test limits for H4 NAND ROM configuration. These constants were determined using benchmarks from the ONB&TR. sl@0: const TReal KBasicH4NAND = 3; sl@0: const TReal KSecurityInfoRetrievedH4NAND = 9; sl@0: const TReal KDefaultResolverH4NAND = 2; sl@0: const TReal KCustomResolverH4NAND = 8; sl@0: const TReal KDllLoadedH4NAND = 7; sl@0: const TReal KFetchExtendedInterfaceH4NAND = 1; sl@0: const TReal KListExtendedInterfacesH4NAND = 1; sl@0: const TReal KExtendedInterfacesMatchedH4NAND = 2; sl@0: // Start-up urel/armv5 test limits for H6 RAM(non-NAND) hardware configuration. These constants were determined using benchmarks from the ONB&TR. sl@0: const TReal KBasicH6RAM = 1; sl@0: const TReal KSecurityInfoRetrievedH6RAM = 1.5; sl@0: const TReal KDefaultResolverH6RAM = 1; sl@0: const TReal KCustomResolverH6RAM = 1.5; sl@0: const TReal KDllLoadedH6RAM = 1; sl@0: const TReal KFetchExtendedInterfaceH6RAM = 1; sl@0: const TReal KListExtendedInterfacesH6RAM = 1; sl@0: const TReal KExtendedInterfacesMatchedH6RAM = 1; sl@0: // Start-up urel/armv5 test limits for H6 NAND ROM configuration. These constants were determined using benchmarks from the ONB&TR. sl@0: const TReal KBasicH6NAND = 1.5; sl@0: const TReal KSecurityInfoRetrievedH6NAND = 4; sl@0: const TReal KDefaultResolverH6NAND = 1; sl@0: const TReal KCustomResolverH6NAND = 4; sl@0: const TReal KDllLoadedH6NAND = 3; sl@0: const TReal KFetchExtendedInterfaceH6NAND = 1; sl@0: const TReal KListExtendedInterfacesH6NAND = 1; sl@0: const TReal KExtendedInterfacesMatchedH6NAND = 1; sl@0: //Specify the number of iterations to do to obtain the average value for API time measurement sl@0: const TInt KNumberIteration=10; sl@0: #endif // __ECOM_SERVER_PERFORMANCE__ sl@0: sl@0: CEComClientRequestsPerfTest::CEComClientRequestsPerfTest() : CEComPerfTestBase(KEComClientRequestsPerfTest) sl@0: { sl@0: } sl@0: sl@0: CEComClientRequestsPerfTest::~CEComClientRequestsPerfTest() sl@0: { sl@0: } sl@0: sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: void CEComClientRequestsPerfTest::WaitForDllUnload() sl@0: { sl@0: #if defined(__EPOC32__) && !defined(_DEBUG) sl@0: // Timeout to unload dll when lazy unload is enabled - which it is by default sl@0: // Used only for HW release builds sl@0: const TInt32 KLazyUnloadTimeout = 150000000; // 2.5 minutes sl@0: sl@0: // Wait for DLL to unload - target release builds only sl@0: User::After(KLazyUnloadTimeout); sl@0: #else sl@0: INFO_PRINTF1(_L("*** WARNING: Use results with care no delay for DLL to unload ***\n")); sl@0: #endif // #if defined(__EPOC32__) && !defined(_DEBUG) sl@0: sl@0: } sl@0: #endif // __ECOM_SERVER_PERFORMANCE__ sl@0: sl@0: /* sl@0: Test cases covered in the test step: sl@0: sl@0: 1. Time calls to ListImplementationsL and CreateImplementationL without resolver, with default resolver and sl@0: with custom resolver under various conditions. sl@0: 1.1 ListImplementationL performance testing without extended interfaces. sl@0: 1.2 CreateImplementationL performance testing without extended interfaces. sl@0: 1.3 ListImplementationL performance testing with extended interfaces.(TestCaseID:SYSLIB-ECOM-CT-3598) sl@0: 1.4 CreateImplementationL performance testing with extended interfaces.(TestCaseID:SYSLIB-ECOM-CT-3599) sl@0: sl@0: 2. Time calls to GetExtendedInterfaceL and ListExtendedInterfacesL under various conditions. sl@0: 2.1 ListExtendedInterfacesL performance testing.(TestCaseID:SYSLIB-ECOM-CT-3600) sl@0: 2.2 GetExtendedInterfaceL performance testing.(TestCaseID: SYSLIB-ECOM-CT-3601) sl@0: sl@0: 1.3,1.4,2.1 and 2.2 are test cases for EC43 sl@0: @return EPass if the test completed successfully and the performance of the client calls are within the maximum sl@0: */ sl@0: TVerdict CEComClientRequestsPerfTest::doTestStepL() sl@0: { sl@0: #ifdef __ECOM_SERVER_PERFORMANCE__ sl@0: RImplInfoPtrArray ifArray; sl@0: RArray extendedInterfaces; sl@0: CleanupClosePushL(extendedInterfaces); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid1); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid2); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid3); sl@0: //set configuration-dependent timing limits (for non-NAND and NAND ROM configurations) sl@0: TReal limitBasic = 0; sl@0: TReal limitSecurityInfoRetrieved = 0; sl@0: TReal limitDefaultResolver = 0; sl@0: TReal limitCustomResolver = 0; sl@0: TReal limitDllLoaded = 0; sl@0: TReal limitFetchExtendedInterface = 0; sl@0: TReal limitListExtendedInterfaces = 0; sl@0: TReal limitExtendedInterfaceMatched = 0; sl@0: sl@0: THardwareConfiguration hardware_configuration = EComTestUtils::GetHardwareConfiguration(); sl@0: switch (hardware_configuration) sl@0: { sl@0: case EPlatformH2RAM: sl@0: limitBasic = KBasicH2RAM; sl@0: limitSecurityInfoRetrieved = KSecurityInfoRetrievedH2RAM; sl@0: limitDefaultResolver = KDefaultResolverH2RAM; sl@0: limitCustomResolver = KCustomResolverH2RAM; sl@0: limitDllLoaded = KDllLoadedH2RAM; sl@0: limitFetchExtendedInterface = KFetchExtendedInterfaceH2RAM; sl@0: limitListExtendedInterfaces = KListExtendedInterfacesH2RAM; sl@0: limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH2RAM; 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: limitBasic = KBasicH4RAM; sl@0: limitSecurityInfoRetrieved = KSecurityInfoRetrievedH4RAM; sl@0: limitDefaultResolver = KDefaultResolverH4RAM; sl@0: limitCustomResolver = KCustomResolverH4RAM; sl@0: limitDllLoaded = KDllLoadedH4RAM; sl@0: limitFetchExtendedInterface = KFetchExtendedInterfaceH4RAM; sl@0: limitListExtendedInterfaces = KListExtendedInterfacesH4RAM; sl@0: limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH4RAM; sl@0: INFO_PRINTF1(_L("Hardware configuration: H4 RAM")); sl@0: break; sl@0: sl@0: case EPlatformH4NAND: sl@0: limitBasic = KBasicH4NAND; sl@0: limitSecurityInfoRetrieved = KSecurityInfoRetrievedH4NAND; sl@0: limitDefaultResolver = KDefaultResolverH4NAND; sl@0: limitCustomResolver = KCustomResolverH4NAND; sl@0: limitDllLoaded = KDllLoadedH4NAND; sl@0: limitFetchExtendedInterface = KFetchExtendedInterfaceH4NAND; sl@0: limitListExtendedInterfaces = KListExtendedInterfacesH4NAND; sl@0: limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH4NAND; 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: limitBasic = KBasicH6RAM; sl@0: limitSecurityInfoRetrieved = KSecurityInfoRetrievedH6RAM; sl@0: limitDefaultResolver = KDefaultResolverH6RAM; sl@0: limitCustomResolver = KCustomResolverH6RAM; sl@0: limitDllLoaded = KDllLoadedH6RAM; sl@0: limitFetchExtendedInterface = KFetchExtendedInterfaceH6RAM; sl@0: limitListExtendedInterfaces = KListExtendedInterfacesH6RAM; sl@0: limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH6RAM; sl@0: INFO_PRINTF1(_L("Hardware configuration: H6 RAM")); sl@0: break; sl@0: sl@0: case EPlatformH6NAND: sl@0: limitBasic = KBasicH6NAND; sl@0: limitSecurityInfoRetrieved = KSecurityInfoRetrievedH6NAND; sl@0: limitDefaultResolver = KDefaultResolverH6NAND; sl@0: limitCustomResolver = KCustomResolverH6NAND; sl@0: limitDllLoaded = KDllLoadedH6NAND; sl@0: limitFetchExtendedInterface = KFetchExtendedInterfaceH6NAND; sl@0: limitListExtendedInterfaces = KListExtendedInterfacesH6NAND; sl@0: limitExtendedInterfaceMatched = KExtendedInterfacesMatchedH6NAND; sl@0: INFO_PRINTF1(_L("Hardware configuration: H6 NAND")); sl@0: break; 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: INFO_PRINTF1(_L("***Unrecognized platform!***")); sl@0: SetTestStepResult(EFail); sl@0: break; sl@0: } sl@0: sl@0: // sl@0: // 1.1 ListImplementationL performance testing without extended interfaces. sl@0: // sl@0: TInt totalTime=0; sl@0: INFO_PRINTF1(_L("Time servicing ListImplementationsL requests - each request returns 4 implementations:\n")); sl@0: // sl@0: // Time ListImplementationsL without resolver sl@0: // sl@0: TInt startTime = User::FastCounter(); sl@0: REComSession::ListImplementationsL(KUidListImplTestInterface, ifArray); sl@0: TInt endTime = User::FastCounter(); sl@0: TEST(ifArray.Count()==4); sl@0: ifArray.ResetAndDestroy(); sl@0: TReal netTime = FastCountToMilliseconds(endTime-startTime); sl@0: CheckPerformance(netTime, limitBasic+limitSecurityInfoRetrieved, _L("Call with: no resolver, security info retrieval")); sl@0: sl@0: // sl@0: // Average Time over KNumberIteration ListImplementationsL without resolver when the DLL security info is cached sl@0: // sl@0: totalTime=0; sl@0: for (TInt i=0;i(REComSession::CreateImplementationL(KExample10InterfaceUid, extendedInterfaces, ecomDestructorId, params)); sl@0: endTime = User::FastCounter(); sl@0: netTime = FastCountToMilliseconds(endTime-startTime); sl@0: CheckPerformance(netTime, limitBasic+limitDefaultResolver+limitDllLoaded+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, default resolver, dll to be loaded, security info cached")); sl@0: sl@0: // sl@0: // Average Time over KNumberIteration CreateImplementation with extended interfaces, default resolver when the DLL security info is cached and dll is already sl@0: // loaded sl@0: // sl@0: totalTime = 0; sl@0: for (TInt i = 0; i < KNumberIteration; i++) sl@0: { sl@0: startTime = User::FastCounter(); sl@0: dllPtr2 = reinterpret_cast(REComSession::CreateImplementationL(KExample10InterfaceUid, extendedInterfaces, ecomDestructorId2, params)); sl@0: endTime = User::FastCounter(); sl@0: totalTime += endTime-startTime; sl@0: REComSession::DestroyedImplementation(ecomDestructorId2); sl@0: delete dllPtr2; sl@0: } sl@0: REComSession::DestroyedImplementation(ecomDestructorId); sl@0: delete dllPtr; sl@0: netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration; sl@0: CheckPerformance(netTime, limitBasic+limitDefaultResolver+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, default resolver, dll already loaded, security info cached")); sl@0: REComSession::FinalClose(); sl@0: WaitForDllUnload(); sl@0: sl@0: // sl@0: // Time CreateImplementation with extended interfaces, custom resolver when the DLL security info cached and dll must be loaded sl@0: // sl@0: startTime = User::FastCounter(); sl@0: dllPtr = reinterpret_cast(REComSession::CreateImplementationL( sl@0: KExample10InterfaceUid, extendedInterfaces, ecomDestructorId, params, KCustomResolverImplementationUid)); sl@0: endTime = User::FastCounter(); sl@0: netTime = FastCountToMilliseconds(endTime-startTime); sl@0: CheckPerformance(netTime, limitBasic+limitCustomResolver+limitDllLoaded+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, custom resolver, dll to be loaded, security info cached")); sl@0: sl@0: // sl@0: // Average Time over KNumberIteration CreateImplementation with extended interfaces, custom resolver when the DLL security info is cached and dll is already sl@0: // loaded sl@0: // sl@0: totalTime = 0; sl@0: for (TInt i = 0; i < KNumberIteration; i++) sl@0: { sl@0: startTime = User::FastCounter(); sl@0: dllPtr2 = reinterpret_cast(REComSession::CreateImplementationL( sl@0: KExample10InterfaceUid, extendedInterfaces, ecomDestructorId2, params, KCustomResolverImplementationUid)); sl@0: endTime = User::FastCounter(); sl@0: totalTime += endTime-startTime; sl@0: REComSession::DestroyedImplementation(ecomDestructorId2); sl@0: delete dllPtr2; sl@0: } sl@0: REComSession::DestroyedImplementation(ecomDestructorId); sl@0: delete dllPtr; sl@0: netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration; sl@0: CheckPerformance(netTime, limitBasic+limitCustomResolver+limitExtendedInterfaceMatched, _L("Call with: extended interfaces, custom resolver, dll already loaded, security info cached")); sl@0: sl@0: REComSession::FinalClose(); sl@0: WaitForDllUnload(); sl@0: CleanupStack::PopAndDestroy(&extendedInterfaces); sl@0: sl@0: // sl@0: // 2.1 ListExtendedInterfacesL performance testing. sl@0: // sl@0: RArray ifInfo; sl@0: CleanupClosePushL(ifInfo); sl@0: totalTime = 0; sl@0: for (TInt i = 0; i < KNumberIteration; i++) sl@0: { sl@0: startTime = User::FastCounter(); sl@0: REComSession::ListExtendedInterfacesL(KExample10ImplementationUid,ifInfo); sl@0: endTime = User::FastCounter(); sl@0: // Ensure test is valid by testing return parameters sl@0: TEST(ifInfo.Count() == 3); sl@0: totalTime += endTime-startTime; sl@0: ifInfo.Reset(); sl@0: } sl@0: netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration; sl@0: CheckPerformance(netTime, limitListExtendedInterfaces, _L("List extended interface. Three interfaces returned.")); sl@0: sl@0: // Test with no interfaces returned sl@0: totalTime = 0; sl@0: for (TInt i = 0; i < KNumberIteration; i++) sl@0: { sl@0: startTime = User::FastCounter(); sl@0: REComSession::ListExtendedInterfacesL(KExample10ImplementationUid2,ifInfo); sl@0: endTime = User::FastCounter(); sl@0: // Ensure test is valid by testing return parameters sl@0: TEST(ifInfo.Count() == 0); sl@0: totalTime += endTime-startTime; sl@0: ifInfo.Reset(); sl@0: } sl@0: netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration; sl@0: CheckPerformance(netTime, limitListExtendedInterfaces, _L("List extended interface. No interface returned.")); sl@0: CleanupStack::PopAndDestroy(&ifInfo); sl@0: sl@0: // sl@0: // 2.2 GetExtendedInterfaceL performance testing. sl@0: // sl@0: sl@0: TUid instanceKey; sl@0: // Set up some empty initialisation parameters sl@0: CExampleInterface::TExampleInterfaceInitParams initParams; sl@0: initParams.integer = 0; sl@0: initParams.descriptor = NULL; sl@0: dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(KExample10ImplementationUid, sl@0: instanceKey, sl@0: &initParams)); sl@0: sl@0: // Call extended interface here. sl@0: totalTime = 0; sl@0: for (TInt i = 0; i < KNumberIteration; i++) sl@0: { sl@0: startTime = User::FastCounter(); sl@0: MExampleInterfaceExtended* ext1 = static_cast(REComSession::GetExtendedInterfaceL(instanceKey, KExtendedInterfaceUid1 )); sl@0: endTime = User::FastCounter(); sl@0: totalTime += endTime - startTime; sl@0: } sl@0: netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration; sl@0: CheckPerformance(netTime, limitFetchExtendedInterface, _L("Get extended interface. Interface is part of main instantiation object.")); sl@0: totalTime = 0; sl@0: for (TInt i = 0; i < KNumberIteration; i++) sl@0: { sl@0: startTime = User::FastCounter(); sl@0: MExampleInterfaceExtended2* ext2 = static_cast(REComSession::GetExtendedInterfaceL(instanceKey, KExtendedInterfaceUid2 )); sl@0: endTime = User::FastCounter(); sl@0: totalTime += endTime - startTime; sl@0: } sl@0: netTime = (FastCountToMilliseconds(totalTime))/KNumberIteration; sl@0: CheckPerformance(netTime, limitFetchExtendedInterface, _L("Get extended interface. Interface is separate object.")); sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: delete dllPtr; sl@0: REComSession::FinalClose(); sl@0: #else sl@0: MacroNotDefinedError(); sl@0: #endif // __ECOM_SERVER_PERFORMANCE__ sl@0: return TestStepResult(); sl@0: }