1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicstest/graphicstestharness/src/tprofiler.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,583 @@
1.4 +// Copyright (c) 2008-2010 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 + @test
1.22 + @internalComponent - Internal Symbian test code
1.23 +*/
1.24 +
1.25 +#include <test/TestExecuteStepBase.h>
1.26 +#include <e32math.h>
1.27 +#include <hal.h>
1.28 +#include "tprofiler.h"
1.29 +
1.30 +
1.31 +#define PROFILER_TEST(a) (iTestStep.testBooleanTrue((a), (TText8*)__FILE__, __LINE__))
1.32 +
1.33 +
1.34 +#define PROFILER_INFO_PRINTF1(p1) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
1.35 +#define PROFILER_INFO_PRINTF2(p1, p2) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
1.36 +#define PROFILER_INFO_PRINTF3(p1, p2, p3) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3))
1.37 +#define PROFILER_INFO_PRINTF4(p1, p2, p3, p4) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
1.38 +#define PROFILER_INFO_PRINTF5(p1, p2, p3, p4, p5) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
1.39 +#define PROFILER_INFO_PRINTF6(p1, p2, p3, p4, p5, p6) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
1.40 +#define PROFILER_INFO_PRINTF7(p1, p2, p3, p4, p5, p6, p7) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
1.41 +
1.42 +#define PROFILER_WARN_PRINTF1(p1) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1))
1.43 +#define PROFILER_WARN_PRINTF2(p1, p2) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2))
1.44 +#define PROFILER_WARN_PRINTF3(p1, p2, p3) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3))
1.45 +#define PROFILER_WARN_PRINTF4(p1, p2, p3, p4) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4))
1.46 +#define PROFILER_WARN_PRINTF5(p1, p2, p3, p4, p5) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5))
1.47 +#define PROFILER_WARN_PRINTF6(p1, p2, p3, p4, p5, p6) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6))
1.48 +#define PROFILER_WARN_PRINTF7(p1, p2, p3, p4, p5, p6, p7) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
1.49 +
1.50 +#define PROFILER_ERR_PRINTF1(p1) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1))
1.51 +#define PROFILER_ERR_PRINTF2(p1, p2) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2))
1.52 +#define PROFILER_ERR_PRINTF3(p1, p2, p3) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)) ;
1.53 +#define PROFILER_ERR_PRINTF4(p1, p2, p3, p4) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4))
1.54 +#define PROFILER_ERR_PRINTF5(p1, p2, p3, p4, p5) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5))
1.55 +#define PROFILER_ERR_PRINTF6(p1, p2, p3, p4, p5, p6) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6))
1.56 +#define PROFILER_ERR_PRINTF7(p1, p2, p3, p4, p5, p6, p7) iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7))
1.57 +
1.58 +
1.59 +CTProfiler::CTProfiler(CTestStep& aTestStep) :
1.60 + iTestStep(aTestStep)
1.61 + {
1.62 + }
1.63 +
1.64 +EXPORT_C CTProfiler::~CTProfiler()
1.65 + {
1.66 + iResults.Reset();
1.67 + iResultsTimingOrder.Reset();
1.68 + }
1.69 +
1.70 +EXPORT_C CTProfiler* CTProfiler::NewL(CTestStep& aTestStep)
1.71 + {
1.72 + CTProfiler* profiler = new (ELeave) CTProfiler(aTestStep);
1.73 + CleanupStack::PushL(profiler);
1.74 + profiler->ConstructL();
1.75 + CleanupStack::Pop();
1.76 + return profiler;
1.77 + }
1.78 +
1.79 +void CTProfiler::ConstructL()
1.80 + {
1.81 + User::LeaveIfError((HAL::Get(HALData::EFastCounterFrequency, iFreq)));
1.82 + PROFILER_INFO_PRINTF2(_L("FastCounterFrequency: %i Hz"), iFreq);
1.83 +
1.84 + if(iFreq == 0)
1.85 + {
1.86 + User::Leave(KErrDivideByZero);
1.87 + }
1.88 + }
1.89 +
1.90 +EXPORT_C void CTProfiler::StartTimer()
1.91 + {
1.92 + iStart = User::FastCounter();
1.93 + }
1.94 +
1.95 +EXPORT_C TInt64 CTProfiler::StopTimer()
1.96 + {
1.97 + iEnd = User::FastCounter();
1.98 + // wrap around automatically dealt with by two's complement arithmetic as long as all variables are unsigned int
1.99 + iDiff += iEnd - iStart;
1.100 + TInt64 difftime = (1000000*(TInt64)iDiff) / (TInt64)iFreq;
1.101 + return difftime;
1.102 + }
1.103 +
1.104 +/**
1.105 +Initalises the results. Must be called before MarkResultSet
1.106 +*/
1.107 +EXPORT_C void CTProfiler::InitResults()
1.108 + {
1.109 + PROFILER_TEST(!iResultsInitalised);
1.110 + iResultsInitalised = ETrue;
1.111 + iDiff = 0;
1.112 + iResults.Reset();
1.113 + iSessionId = Math::Random();
1.114 + if (iSessionId < 1000000)
1.115 + {
1.116 + /*
1.117 + * The reason for bumping up low session id values is that it allows
1.118 + * us to in the future to re-compact the session ids into a unique
1.119 + * number range from zero to one million. Duplicate session id values
1.120 + * generated on the same day can cause confusion but will be very rare.
1.121 + */
1.122 + iSessionId += 1000000;
1.123 + }
1.124 +
1.125 + /*
1.126 + * The build system needs to know the session id because it maps it to
1.127 + * the job ID it is running, so it can map test results to a particular
1.128 + * build in question.
1.129 + */
1.130 + PROFILER_INFO_PRINTF2(_L("SQL_SESSION_ID=%u"), iSessionId);
1.131 + StartTimer();
1.132 + }
1.133 +
1.134 +/**
1.135 +Records set current time. Can be called multiple times so an average can be taken.
1.136 +*/
1.137 +EXPORT_C void CTProfiler::MarkResultSetL()
1.138 + {
1.139 + MarkResultSetAndSuspendL();
1.140 + StartTimer();
1.141 + }
1.142 +
1.143 +/**
1.144 +Records set current time. Unlike MarkResultSetL() the function doesn't
1.145 +restart the timer at the end. The following operations will not be
1.146 +included into benchmark mesuarment. To resume the profiling the user must
1.147 +start the timer.
1.148 +@see StartTimer()
1.149 +@see MarkResultSetL()
1.150 +Can be called multiple times so an average can be taken.
1.151 +*/
1.152 +EXPORT_C void CTProfiler::MarkResultSetAndSuspendL()
1.153 + {
1.154 + TUint32 res = StopTimer();
1.155 + iResults.InsertInUnsignedKeyOrderAllowRepeatsL(res);
1.156 + if(iStoreResultInTimingOrder)
1.157 + {
1.158 + iResultsTimingOrder.AppendL(res);
1.159 + }
1.160 + iDiff = 0;
1.161 + PROFILER_TEST(iResultsInitalised);
1.162 + }
1.163 +
1.164 +/**
1.165 +Frees all memory allocated by results capturing methods like MarkResultSetL().
1.166 +*/
1.167 +EXPORT_C void CTProfiler::FreeResultsMemory()
1.168 + {
1.169 + iResults.Reset();
1.170 + iResultsTimingOrder.Reset();
1.171 + }
1.172 +
1.173 +/**
1.174 +Returns the trimmed mean of a set of results. i.e. Trims off the 20% smallest and the 20% largest of the data results.
1.175 +*/
1.176 +EXPORT_C TUint32 CTProfiler::GetTrimedMean()
1.177 + {
1.178 + TInt64 total = 0;
1.179 + if (iResults.Count() <= 50)
1.180 + {
1.181 + PROFILER_WARN_PRINTF2(_L("Not enough results for trimming - need more than 50, but got %d"), iResults.Count());
1.182 + }
1.183 + if (iResults.Count() == 0) // If iResults is zero then do nothing
1.184 + {
1.185 + return 0;
1.186 + }
1.187 +
1.188 + TInt twentyPercentCount = iResults.Count()/5;
1.189 + for (TInt count = twentyPercentCount; count < iResults.Count()-twentyPercentCount; count++)
1.190 + {
1.191 + total += iResults[count];
1.192 + }
1.193 + return ((TUint32)(total/(iResults.Count()-(twentyPercentCount*2))));
1.194 + }
1.195 +
1.196 +EXPORT_C TInt CTProfiler::PercentageChange(TInt aFirstTime, TInt aSecondTime)
1.197 + {
1.198 + return ((aFirstTime - aSecondTime)*100) / aFirstTime;
1.199 + }
1.200 +
1.201 +/**
1.202 +Finds the maximum time taken
1.203 +*/
1.204 +EXPORT_C TUint32 CTProfiler::TimeMax()
1.205 + {
1.206 + if (iResults.Count() == 0)
1.207 + {
1.208 + return 0;
1.209 + }
1.210 + TUint32 result = iResults[0];
1.211 + for(TInt i = 0; i < iResults.Count(); i++)
1.212 + {
1.213 + if(iResults[i] > result)
1.214 + result = iResults[i];
1.215 + }
1.216 + return result;
1.217 + }
1.218 +
1.219 +/**
1.220 +Finds the minimum time taken
1.221 +*/
1.222 +EXPORT_C TUint32 CTProfiler::TimeMin()
1.223 + {
1.224 + if (iResults.Count() == 0)
1.225 + {
1.226 + return 0;
1.227 + }
1.228 + TUint32 result = iResults[0];
1.229 + for(TInt i = 0; i < iResults.Count(); i++)
1.230 + {
1.231 + if(iResults[i] < result)
1.232 + result = iResults[i];
1.233 + }
1.234 + return result;
1.235 + }
1.236 +
1.237 +/**
1.238 +Reports analysis results
1.239 +
1.240 +@param aTestName is the name of the test case
1.241 +@param aRotation is the screen rotation being used in the test
1.242 +@param aSrcScreenMode is the source screen mode being used,
1.243 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.244 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.245 +@param aIters is the number of iterations used in the test
1.246 +*/
1.247 +EXPORT_C void CTProfiler::ResultsAnalysis(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
1.248 + {
1.249 + PROFILER_TEST(iResultsInitalised);
1.250 + TBuf<128> variation;
1.251 + variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode,aIters);
1.252 + TBuf<128> variationMax;
1.253 + variationMax.Format(KMaxTime, &variation);
1.254 + TBuf<128> variationMin;
1.255 + variationMin.Format(KMinTime, &variation);
1.256 + TBuf<128> variationTrimmedMean;
1.257 + variationTrimmedMean.Format(KTrimmedMean, &variation);
1.258 +
1.259 + SqlInsert(&aTestName, &variationTrimmedMean, &KMicroSeconds, GetTrimedMean());
1.260 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.261 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.262 +
1.263 + iResultsInitalised = EFalse;
1.264 + }
1.265 +
1.266 +/**
1.267 +Reports analysis results for pixel rates
1.268 +
1.269 +@param aTestName is the name of the test case
1.270 +@param aRotation is the screen rotation being used in the test
1.271 +@param aSrcScreenMode is the source screen mode being used,
1.272 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.273 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.274 +@param aIters is the number of iterations used in the test
1.275 +@param aNumPixels is the number of pixels rendered
1.276 +*/
1.277 +EXPORT_C void CTProfiler::ResultsAnalysisPixelRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
1.278 + {
1.279 + PROFILER_TEST(iResultsInitalised);
1.280 +
1.281 + TReal time = (TReal)iResults[0] / 1000000;
1.282 + TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
1.283 +
1.284 + TBuf<128> variation;
1.285 + variation.Format(KVariationPPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumPixelsPerIteration);
1.286 + TBuf<128> variationMax;
1.287 + variationMax.Format(KMaxTime, &variation);
1.288 + TBuf<128> variationMin;
1.289 + variationMin.Format(KMinTime, &variation);
1.290 +
1.291 + SqlInsert(&aTestName, &variation, &KPixelsPerSecond, pixelRate);
1.292 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.293 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.294 +
1.295 + iResultsInitalised = EFalse;
1.296 + }
1.297 +
1.298 +/**
1.299 +Reports analysis results for character rates
1.300 +
1.301 +@param aTestName is the name of the test case
1.302 +@param aRotation is the screen rotation being used in the test
1.303 +@param aSrcScreenMode is the source screen mode being used,
1.304 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.305 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.306 +@param aIters is the number of iterations used in the test
1.307 +@param aNumChars is the number of characters rendered
1.308 +*/
1.309 +EXPORT_C void CTProfiler::ResultsAnalysisCharacterRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumCharsPerIteration)
1.310 + {
1.311 + PROFILER_TEST(iResultsInitalised);
1.312 + TReal time = (TReal)iResults[0] / 1000000;
1.313 + TInt32 characterRate = aNumCharsPerIteration*aIters/time;
1.314 +
1.315 + TBuf<128> variation;
1.316 + variation.Format(KVariationCPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumCharsPerIteration);
1.317 + TBuf<128> variationMax;
1.318 + variationMax.Format(KMaxTime, &variation);
1.319 + TBuf<128> variationMin;
1.320 + variationMin.Format(KMinTime, &variation);
1.321 +
1.322 + SqlInsert(&aTestName, &variation, &KCharacterRate, characterRate);
1.323 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.324 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.325 +
1.326 + iResultsInitalised = EFalse;
1.327 + }
1.328 +
1.329 +/**
1.330 +Reports analysis results when there is one total result given the number of itertions
1.331 +This function should only be used if you cannot obtain the times for each iteration of
1.332 +the test and ResultsAnalysis cannot be used.
1.333 +
1.334 +@param aTestName is the name of the test case
1.335 +@param aRotation is the screen rotation being used in the test
1.336 +@param aSrcScreenMode is the source screen mode being used,
1.337 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.338 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.339 +@param aIters is the number of iterations used in the test
1.340 +*/
1.341 +EXPORT_C void CTProfiler::ResultsAnalysisAverageByIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
1.342 + {
1.343 + PROFILER_TEST(iResultsInitalised);
1.344 +
1.345 + TUint32 result = iResults[0]/aIters;
1.346 +
1.347 + TBuf<128> variation;
1.348 + variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode,aIters);
1.349 + TBuf<128> variationMax;
1.350 + variationMax.Format(KMaxTime, &variation);
1.351 + TBuf<128> variationMin;
1.352 + variationMin.Format(KMinTime, &variation);
1.353 +
1.354 + SqlInsert(&aTestName, &variation, &KMicroSeconds, result);
1.355 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.356 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.357 +
1.358 + iResultsInitalised = EFalse;
1.359 + }
1.360 +
1.361 +/**
1.362 + * Generate an SQL insert statement into the logs, intended for subsequent
1.363 + * extraction by a script to load into the database.
1.364 + * Inserts data fields for
1.365 + * (sessionid, testname, testattribute, testunits, testresultvalue).
1.366 + * An example insertion:
1.367 + * <code>
1.368 + * SQL_UPLOAD_VERSION_0:insert into performance.testresultstable (sessionid, testname, testattribute, testunits, testresultvalue) values
1.369 + * SQL_UPLOAD_VERSION_0:('1136416860', 'GRAPHICS-UI-BENCH-S60-0009', 'Rot_0_SrcMode_0_DestMode_0_Iters_25', 'pixels/second', '394159');
1.370 + * </code>
1.371 + *
1.372 + * @param aTestName Column testname
1.373 + * @param aTestAttribute Column testattribute
1.374 + * @param aTestUnit Column testunits
1.375 + * @param aTestResultValue Column testresultvalue
1.376 + */
1.377 +EXPORT_C void CTProfiler::SqlInsert(const TDesC* aTestName, const TDesC* aTestAttribute, const TDesC* aTestUnit, TInt32 aTestResultValue)
1.378 + {
1.379 + TBuf<200>scratchPad;
1.380 + /*
1.381 + * There is a 256 character limit on logging output, and a 7 vararg limit
1.382 + * on the macro we can use to issue printfs to the test framework. Each
1.383 + * output line which has SQL in it needs to have a marker at the front so
1.384 + * that a script can reliably extract the SQL statements. Hence we use
1.385 + * the following incremental strategy of getting our SQL statements output
1.386 + * into the logs.
1.387 + */
1.388 + scratchPad.Format(KSqlInsert);
1.389 + PROFILER_INFO_PRINTF2(_L("%S"), &scratchPad);
1.390 + scratchPad.Format(KSqlData, iSessionId, aTestName, aTestAttribute, aTestUnit, aTestResultValue);
1.391 + PROFILER_INFO_PRINTF2(_L("%S"), &scratchPad);
1.392 + }
1.393 +
1.394 +/**
1.395 +Reports analysis results for frame rates
1.396 +
1.397 +@param aTestName is the name of the test case
1.398 +@param aRotation is the screen rotation being used in the test
1.399 +@param aSrcScreenMode is the source screen mode being used,
1.400 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.401 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.402 +@param aIters is the number of iterations used in the test
1.403 +@param aNumPixels is the number of pixels rendered
1.404 +*/
1.405 +EXPORT_C void CTProfiler::ResultsAnalysisFrameRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
1.406 + {
1.407 + PROFILER_TEST(iResultsInitalised);
1.408 + TReal time = (TReal)iResults[0] / 1000000;
1.409 + TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
1.410 + TInt32 frameRate = aIters / time;
1.411 +
1.412 + TBuf<128> variation;
1.413 + variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode, aIters);
1.414 + TBuf<128> variationMax;
1.415 + variationMax.Format(KMaxTime, &variation);
1.416 + TBuf<128> variationMin;
1.417 + variationMin.Format(KMinTime, &variation);
1.418 +
1.419 + SqlInsert(&aTestName, &variation, &KPixelsPerSecond, pixelRate);
1.420 + SqlInsert(&aTestName, &variation, &KFrameRate, frameRate);
1.421 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.422 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.423 +
1.424 + iResultsInitalised = EFalse;
1.425 + }
1.426 +
1.427 +/**
1.428 +Reports analysis results for screen rotation rates
1.429 +
1.430 +@param aTestName is the name of the test case
1.431 +@param aRotation is the screen rotation being used in the test
1.432 +@param aSrcScreenMode is the source screen mode being used,
1.433 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.434 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.435 +@param aIters is the number of iterations used in the test
1.436 +@param aNumPixels is the number of pixels rendered
1.437 +*/
1.438 +EXPORT_C void CTProfiler::ResultsAnalysisScreenRotationRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
1.439 + {
1.440 + PROFILER_TEST(iResultsInitalised);
1.441 + TReal time = (TReal)iResults[0] / 1000000;
1.442 + TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
1.443 + TInt32 frameRate = aIters / time;
1.444 +
1.445 + TBuf<128> variation;
1.446 + variation.Format(KVariationPPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumPixelsPerIteration);
1.447 + TBuf<128> variationMax;
1.448 + variationMax.Format(KMaxTime, &variation);
1.449 + TBuf<128> variationMin;
1.450 + variationMin.Format(KMinTime, &variation);
1.451 +
1.452 + SqlInsert(&aTestName, &variation, &KPixelsPerSecond, pixelRate);
1.453 + SqlInsert(&aTestName, &variation, &KFrameRate, frameRate);
1.454 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.455 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.456 +
1.457 + iResultsInitalised = EFalse;
1.458 + }
1.459 +
1.460 +/**
1.461 +Reports analysis results for Z Order Switching rates
1.462 +
1.463 +@param aTestName is the name of the test case
1.464 +@param aZorderSwitching is the z Order Switching being used in the test
1.465 +@param aSrcScreenMode is the source screen mode being used,
1.466 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.467 +@param aIters is the number of iterations used in the test
1.468 +@param aNumPixels is the number of pixels rendered
1.469 +*/
1.470 +EXPORT_C void CTProfiler::ResultsAnalysisZorderSwitchingRate(const TDesC & aTestName, TInt aZorderSwitching, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
1.471 + {
1.472 + PROFILER_TEST(iResultsInitalised);
1.473 + TReal time = (TReal)iResults[0] / 1000000;
1.474 + TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
1.475 + TInt32 frameRate = aIters / time;
1.476 +
1.477 + TBuf<128> variation;
1.478 + variation.Format(KVariationZOrder, aZorderSwitching, aSrcScreenMode, aDstScreenMode, aIters, aNumPixelsPerIteration);
1.479 + TBuf<128> variationMax;
1.480 + variationMax.Format(KMaxTime, &variation);
1.481 + TBuf<128> variationMin;
1.482 + variationMin.Format(KMinTime, &variation);
1.483 +
1.484 + SqlInsert(&aTestName, &variation, &KPixelsPerSecond, pixelRate);
1.485 + SqlInsert(&aTestName, &variation, &KFrameRate, frameRate);
1.486 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.487 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.488 +
1.489 + iResultsInitalised = EFalse;
1.490 + }
1.491 +
1.492 +/**
1.493 +This function calclulates the mean without deleting any of the values from iResults
1.494 +*/
1.495 +EXPORT_C TUint32 CTProfiler::Mean()
1.496 + {
1.497 + TInt64 total = 0;
1.498 + TInt count1 = iResults.Count();
1.499 + for (TInt count = 0; count < iResults.Count(); count++)
1.500 + {
1.501 + total += iResults[count];
1.502 + }
1.503 + return ((TUint32)(total/(iResults.Count())));
1.504 + }
1.505 +
1.506 +
1.507 +/**
1.508 +Reports analysis of results when there are more then one values by calculating the average based on value of iResult.count().
1.509 +
1.510 +@param aTestName is the name of the test case
1.511 +@param aRotation is the screen rotation being used in the test
1.512 +@param aSrcScreenMode is the source screen mode being used,
1.513 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.514 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.515 +@param aIters is the number of iterations used in the test
1.516 +*/
1.517 +EXPORT_C void CTProfiler::ResultsAnalysisAverageByNumberOfIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode,TInt aIters)
1.518 + {
1.519 + PROFILER_TEST(iResultsInitalised);
1.520 + TBuf<128> variation;
1.521 + variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode, aIters);
1.522 + TBuf<128> variationMean;
1.523 + variationMean.Format(KMean, &variation);
1.524 + TBuf<128> variationMax;
1.525 + variationMax.Format(KMaxTime, &variation);
1.526 + TBuf<128> variationMin;
1.527 + variationMin.Format(KMinTime, &variation);
1.528 +
1.529 + SqlInsert(&aTestName, &variationMean, &KMicroSeconds, Mean());
1.530 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.531 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.532 +
1.533 + iResultsInitalised = EFalse;
1.534 + }
1.535 +
1.536 +/**
1.537 +Output all results.
1.538 +*/
1.539 +EXPORT_C void CTProfiler::ShowResultArrayInTimingOrder()
1.540 + {
1.541 + for(TInt i=0; i < iResultsTimingOrder.Count(); i++)
1.542 + {
1.543 + PROFILER_INFO_PRINTF3(_L("iResultsTimingOrder[%4d]: %8d"),i, iResultsTimingOrder[i]);
1.544 + }
1.545 + }
1.546 +
1.547 +/**
1.548 + @param aStoreResultInTimingOrder Signify whether the results should be stored as they coming
1.549 + */
1.550 +EXPORT_C void CTProfiler::SetStoreResultInTimingOrder(TBool aStoreResultInTimingOrder)
1.551 + {
1.552 + iStoreResultInTimingOrder = aStoreResultInTimingOrder;
1.553 + }
1.554 +
1.555 +/**
1.556 +Reports analysis results for glyph rates
1.557 +
1.558 +@param aTestName is the name of the test case
1.559 +@param aRotation is the screen rotation being used in the test
1.560 +@param aSrcScreenMode is the source screen mode being used,
1.561 +i.e. for bitmap display conversion the source and destinations bitmaps maybe different
1.562 +@param aDstScreenMode is the destination screen mode (usually the display screen mode)
1.563 +@param aIters is the number of iterations used in the test
1.564 +@param aNumGlyphs is the number of glyphs used per iteration
1.565 +*/
1.566 +
1.567 +EXPORT_C void CTProfiler::ResultsAnalysisGlyphRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumGlyphsPerIteration)
1.568 + {
1.569 + PROFILER_TEST(iResultsInitalised);
1.570 + TReal time = (iResults.Count() > 0) ? (TReal)iResults[0] / 1000000 : 0;
1.571 + TInt32 glyphRate = aNumGlyphsPerIteration*aIters/time;
1.572 +
1.573 + TBuf<128> variation;
1.574 + variation.Format(KVariationCPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumGlyphsPerIteration);
1.575 + TBuf<128> variationMax;
1.576 + variationMax.Format(KMaxTime, &variation);
1.577 + TBuf<128> variationMin;
1.578 + variationMin.Format(KMinTime, &variation);
1.579 +
1.580 + SqlInsert(&aTestName, &variation, &KGlyphRate, glyphRate);
1.581 + SqlInsert(&aTestName, &variationMax, &KMicroSeconds, TimeMax());
1.582 + SqlInsert(&aTestName, &variationMin, &KMicroSeconds, TimeMin());
1.583 +
1.584 + iResultsInitalised = EFalse;
1.585 + }
1.586 +