os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/TE_EcomGranularityTestStep.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComPerfTest/src/TE_EcomGranularityTestStep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,233 @@
1.4 +// Copyright (c) 2006-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 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @internalComponent
1.22 +*/
1.23 +#include <startup.hrh>
1.24 +#include <hal.h>
1.25 +#include "RegistryData.h"
1.26 +#include "Registrar.h"
1.27 +#include "RegistrarObserver.h"
1.28 +#include "DriveInfo.h"
1.29 +#include "TE_EcomGranularityTestStep.h"
1.30 +
1.31 +_LIT (KMinGranInfUidIndex, "MinGranInfUidIndex");
1.32 +_LIT (KMinGranImplUidIndex, "MinGranImplUidIndex");
1.33 +_LIT (KGranStep, "GranStep");
1.34 +_LIT (KMaxGranInfUidIndex, "MaxGranInfUidIndex");
1.35 +_LIT (KMaxGranImplUidIndex, "MaxGranImplUidIndex");
1.36 +
1.37 +
1.38 +/** Stub class needed to instantiate CRegistrar object. */
1.39 +class CTestRegistrarObserver : public MRegistrarObserver // codescanner::missingcclass
1.40 + {
1.41 +public:
1.42 + // This is a stub. Hence do nothing in notification.
1.43 + void Notification( TInt /*aNotification*/ ) {}
1.44 + };
1.45 +
1.46 +/** Constructor of CEComImplIndexPerfTest */
1.47 +CEComImplIndexPerfTest::CEComImplIndexPerfTest()
1.48 + {
1.49 + SetTestStepName(KEComImplIndexPerfTest);
1.50 + }
1.51 +
1.52 +/** destructor of CEComImplIndexPerfTest */
1.53 +CEComImplIndexPerfTest::~CEComImplIndexPerfTest()
1.54 + {
1.55 + iFs.Close();
1.56 + delete iScheduler;
1.57 + }
1.58 +
1.59 +/** Run the test */
1.60 +TVerdict CEComImplIndexPerfTest::doTestStepL()
1.61 + {
1.62 + iScheduler = new(ELeave) CActiveScheduler;
1.63 + CActiveScheduler::Install(iScheduler);
1.64 + User::LeaveIfError(iFs.Connect());
1.65 +
1.66 + if (ReadConfigParameters() != EPass)
1.67 + {
1.68 + return TestStepResult();
1.69 + }
1.70 +
1.71 + TInt fastCounterFreq;
1.72 + HAL::Get(HAL::EFastCounterFrequency, fastCounterFreq);
1.73 + TUint numTicksInHalfMilliSec = fastCounterFreq / 2000;
1.74 +
1.75 + const TInt KNumberOfDataPts =
1.76 + (iMaxInfUidIndexGranularity - iMinInfUidIndexGranularity) / iGranStep + 1;
1.77 + HBufC* hbufc = HBufC::NewLC(10 * KNumberOfDataPts);
1.78 + TPtr buf = hbufc->Des();
1.79 +
1.80 + // If a sample has the same granularities as the default values
1.81 + // in RegistryData.h, save the result in defaultGranularityTime.
1.82 + TUint32 defaultGranularityTime = 0x7fffffff;
1.83 +
1.84 + TUint32 besttime = 0x7fffffff;
1.85 + TUint32 worsttime = 0;
1.86 + TInt bestAllImplGranularity = 0;
1.87 + TInt bestImplUidGranularity = 0;
1.88 +
1.89 + TUint32 startTicks, endTicks;
1.90 +
1.91 + // Print header for table
1.92 + _LIT(KTableLegend, "Columns = iInterfaceImplIndex granularity, rows = iImplIndex granularity");
1.93 + Logger().Write(KTableLegend);
1.94 +
1.95 + _LIT(KCommaNumber, ",%d");
1.96 + _LIT(KCommaNumber3Wide, ",%3d");
1.97 + _LIT(KNumber2Wide, "%2d");
1.98 +
1.99 + _LIT(KColumnHeadSpace, "--");
1.100 + buf.Copy(KColumnHeadSpace);
1.101 + TInt j;
1.102 + for (j = iMinInfUidIndexGranularity; j <= iMaxInfUidIndexGranularity; j += iGranStep)
1.103 + {
1.104 + buf.AppendFormat(KCommaNumber3Wide, j);
1.105 + }
1.106 + Logger().Write(buf);
1.107 +
1.108 +
1.109 + CTestRegistrarObserver* registrarObserver = new (ELeave) CTestRegistrarObserver;
1.110 + CleanupStack::PushL(registrarObserver);
1.111 +
1.112 + // The two nexting for loops below generate a 2-D table of
1.113 + // discovery time at different combinations of granularities.
1.114 + for (TInt implIndexGranularity = iMinIimplUidIndexGranularity;
1.115 + implIndexGranularity <= iMaxIimplUidIndexGranularity;
1.116 + implIndexGranularity += iGranStep)
1.117 + {
1.118 + buf.Format(KNumber2Wide, implIndexGranularity);
1.119 +
1.120 + for (TInt infIndexGranularity = iMinInfUidIndexGranularity;
1.121 + infIndexGranularity <= iMaxInfUidIndexGranularity;
1.122 + infIndexGranularity += iGranStep)
1.123 + {
1.124 + CRegistryData* registryData = CRegistryData::NewL(iFs, infIndexGranularity, implIndexGranularity);
1.125 + CleanupStack::PushL(registryData);
1.126 +
1.127 + CRegistrar* registrar = CRegistrar::NewL(*registryData, *registrarObserver, iFs);
1.128 + CleanupStack::PushL(registrar);
1.129 +
1.130 + startTicks = User::FastCounter();
1.131 + registrar->ProcessSSAEventL(EStartupStateCriticalStatic);
1.132 + endTicks = User::FastCounter();
1.133 +
1.134 + TUint32 elapsedMilliSec = (endTicks - startTicks + numTicksInHalfMilliSec) * 1000 / fastCounterFreq;
1.135 + buf.AppendFormat(KCommaNumber, elapsedMilliSec);
1.136 +
1.137 + // Look for the best, worst and default granularity times.
1.138 + if ((KDefaultInterfaceImplIndexGranularity == infIndexGranularity) &&
1.139 + (KDefaultImplIndexGranularity == implIndexGranularity))
1.140 + {
1.141 + defaultGranularityTime = elapsedMilliSec;
1.142 + }
1.143 +
1.144 + if (besttime > elapsedMilliSec)
1.145 + {
1.146 + bestAllImplGranularity = infIndexGranularity;
1.147 + bestImplUidGranularity = implIndexGranularity;
1.148 + besttime = elapsedMilliSec;
1.149 + }
1.150 + else if (elapsedMilliSec > worsttime)
1.151 + {
1.152 + worsttime = elapsedMilliSec;
1.153 + }
1.154 +
1.155 + CleanupStack::PopAndDestroy(registrar);
1.156 + CleanupStack::PopAndDestroy(registryData);
1.157 + } // for AllImplementations index granularity
1.158 +
1.159 + // Show one row of result.
1.160 + Logger().Write(buf);
1.161 + } // for impl. UID index granularity
1.162 +
1.163 + CleanupStack::PopAndDestroy(registrarObserver);
1.164 +
1.165 + _LIT(KBest, "Best time is %d milli sec at interface idx granularity %d, Impl UID index granularity %d");
1.166 + INFO_PRINTF4(KBest, besttime, bestAllImplGranularity, bestImplUidGranularity);
1.167 +
1.168 + _LIT(KWorst, "Worst time is %d milli sec.");
1.169 + INFO_PRINTF2(KWorst, worsttime);
1.170 +
1.171 + if (0x7fffffff != defaultGranularityTime)
1.172 + {
1.173 + _LIT(KDefGran, "Default granularities (%d,%d) time is %d.");
1.174 + INFO_PRINTF4(KDefGran, KDefaultInterfaceImplIndexGranularity, KDefaultImplIndexGranularity, defaultGranularityTime);
1.175 + }
1.176 +
1.177 + CleanupStack::PopAndDestroy(hbufc);
1.178 + return TestStepResult();
1.179 + }
1.180 +
1.181 +/** Read test configuration from ini file.
1.182 +*/
1.183 +TVerdict CEComImplIndexPerfTest::ReadConfigParameters()
1.184 + {
1.185 + _LIT (KMissingParamMsg, "Missing %S in config file");
1.186 +
1.187 + if (!GetIntFromConfig(ConfigSection(), KMinGranInfUidIndex, iMinInfUidIndexGranularity))
1.188 + {
1.189 + ERR_PRINTF2(KMissingParamMsg, &KMinGranInfUidIndex);
1.190 + SetTestStepResult(EFail);
1.191 + }
1.192 +
1.193 + if (!GetIntFromConfig(ConfigSection(), KMaxGranInfUidIndex, iMaxInfUidIndexGranularity))
1.194 + {
1.195 + ERR_PRINTF2(KMissingParamMsg, &KMaxGranInfUidIndex);
1.196 + SetTestStepResult(EFail);
1.197 + }
1.198 +
1.199 + if (!GetIntFromConfig(ConfigSection(), KMinGranImplUidIndex, iMinIimplUidIndexGranularity))
1.200 + {
1.201 + ERR_PRINTF2(KMissingParamMsg, &KMinGranImplUidIndex);
1.202 + SetTestStepResult(EFail);
1.203 + }
1.204 +
1.205 + if (!GetIntFromConfig(ConfigSection(), KMaxGranImplUidIndex, iMaxIimplUidIndexGranularity))
1.206 + {
1.207 + ERR_PRINTF2(KMissingParamMsg, &KMaxGranImplUidIndex);
1.208 + SetTestStepResult(EFail);
1.209 + }
1.210 +
1.211 + if (!GetIntFromConfig(ConfigSection(), KGranStep, iGranStep))
1.212 + {
1.213 + ERR_PRINTF2(KMissingParamMsg, &KGranStep);
1.214 + SetTestStepResult(EFail);
1.215 + }
1.216 +
1.217 +#if defined(__WINS__) || defined(__WINSCW__)
1.218 + // On winscw, each data point in the plot takes 3 to 4 seconds (instead
1.219 + // of 0.3 s). A table of 12 columns x 20 rows needs 1000 s.
1.220 + // It is not worthwhile to scan the full range because performance results
1.221 + // on winscw is meaningless anyway. Hence adjust the range to reduce the
1.222 + // stress on over night build.
1.223 +
1.224 + // reduce number of columns to plot
1.225 + iMinInfUidIndexGranularity += (iGranStep * 3);
1.226 + iMaxInfUidIndexGranularity -= iGranStep;
1.227 +
1.228 + iMinIimplUidIndexGranularity += (iGranStep * 4);
1.229 + iMaxIimplUidIndexGranularity -= (iGranStep * 2);
1.230 +
1.231 + INFO_PRINTF1(_L("This test takes too long to run on winscw."));
1.232 + INFO_PRINTF5(_L("Range of I/F idx granularities narrowed to %d,%d, Impl. idx granularity narrowed to %d,%d"), iMinInfUidIndexGranularity, iMaxInfUidIndexGranularity, iMinIimplUidIndexGranularity, iMaxIimplUidIndexGranularity);
1.233 +#endif
1.234 +
1.235 + return TestStepResult();
1.236 + }