os/graphics/graphicstest/graphicstestharness/src/tprofiler.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19  @internalComponent - Internal Symbian test code 
    20 */
    21 
    22 #include <test/TestExecuteStepBase.h>
    23 #include <e32math.h>
    24 #include <hal.h>
    25 #include "tprofiler.h"
    26 
    27 
    28 #define PROFILER_TEST(a)  (iTestStep.testBooleanTrue((a), (TText8*)__FILE__, __LINE__)) 
    29 
    30 
    31 #define PROFILER_INFO_PRINTF1(p1)                            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
    32 #define PROFILER_INFO_PRINTF2(p1, p2)                        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
    33 #define PROFILER_INFO_PRINTF3(p1, p2, p3)                    iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3))
    34 #define PROFILER_INFO_PRINTF4(p1, p2, p3, p4)                iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
    35 #define PROFILER_INFO_PRINTF5(p1, p2, p3, p4, p5)            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
    36 #define PROFILER_INFO_PRINTF6(p1, p2, p3, p4, p5, p6)        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
    37 #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))
    38 
    39 #define PROFILER_WARN_PRINTF1(p1)                            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1))
    40 #define PROFILER_WARN_PRINTF2(p1, p2)                        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2))
    41 #define PROFILER_WARN_PRINTF3(p1, p2, p3)                    iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3))
    42 #define PROFILER_WARN_PRINTF4(p1, p2, p3, p4)                iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4))
    43 #define PROFILER_WARN_PRINTF5(p1, p2, p3, p4, p5)            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5))
    44 #define PROFILER_WARN_PRINTF6(p1, p2, p3, p4, p5, p6)        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6))
    45 #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))
    46 
    47 #define PROFILER_ERR_PRINTF1(p1)                             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1)) 
    48 #define PROFILER_ERR_PRINTF2(p1, p2)                         iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)) 
    49 #define PROFILER_ERR_PRINTF3(p1, p2, p3)                     iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)) ;
    50 #define PROFILER_ERR_PRINTF4(p1, p2, p3, p4)                 iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4)) 
    51 #define PROFILER_ERR_PRINTF5(p1, p2, p3, p4, p5)             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5)) 
    52 #define PROFILER_ERR_PRINTF6(p1, p2, p3, p4, p5, p6)         iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6)) 
    53 #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))
    54 
    55 
    56 CTProfiler::CTProfiler(CTestStep& aTestStep) :
    57     iTestStep(aTestStep)
    58     {
    59     }
    60 
    61 EXPORT_C CTProfiler::~CTProfiler()
    62     {   
    63     iResults.Reset();
    64     iResultsTimingOrder.Reset();
    65     }
    66 
    67 EXPORT_C CTProfiler* CTProfiler::NewL(CTestStep& aTestStep)
    68     {
    69     CTProfiler* profiler = new (ELeave) CTProfiler(aTestStep);
    70     CleanupStack::PushL(profiler);
    71     profiler->ConstructL();
    72     CleanupStack::Pop();
    73     return profiler;
    74     }
    75 
    76 void CTProfiler::ConstructL()
    77     {
    78     User::LeaveIfError((HAL::Get(HALData::EFastCounterFrequency, iFreq)));
    79     PROFILER_INFO_PRINTF2(_L("FastCounterFrequency: %i   Hz"), iFreq);
    80     
    81     if(iFreq == 0)
    82         {
    83         User::Leave(KErrDivideByZero);
    84         }
    85     }
    86 
    87 EXPORT_C void CTProfiler::StartTimer()
    88     {
    89     iStart = User::FastCounter();
    90     }
    91 
    92 EXPORT_C TInt64 CTProfiler::StopTimer()
    93     {
    94     iEnd = User::FastCounter();
    95     // wrap around automatically dealt with by two's complement arithmetic as long as all variables are unsigned int
    96     iDiff += iEnd - iStart;
    97     TInt64 difftime = (1000000*(TInt64)iDiff) / (TInt64)iFreq;
    98     return difftime;
    99     }
   100 
   101 /**
   102 Initalises the results. Must be called before MarkResultSet
   103 */
   104 EXPORT_C void CTProfiler::InitResults()
   105     {
   106     PROFILER_TEST(!iResultsInitalised);
   107     iResultsInitalised = ETrue;
   108     iDiff = 0;
   109     iResults.Reset();
   110     iSessionId = Math::Random();
   111     if (iSessionId < 1000000)
   112         {
   113         /*
   114          * The reason for bumping up low session id values is that it allows
   115          * us to in the future to re-compact the session ids into a unique
   116          * number range from zero to one million.  Duplicate session id values
   117          * generated on the same day can cause confusion but will be very rare.
   118          */
   119         iSessionId += 1000000;
   120         }
   121     
   122     /*
   123      * The build system needs to know the session id because it maps it to
   124      * the job ID it is running, so it can map test results to a particular
   125      * build in question.
   126      */
   127     PROFILER_INFO_PRINTF2(_L("SQL_SESSION_ID=%u"), iSessionId);
   128     StartTimer();
   129     }
   130 
   131 /**
   132 Records set current time. Can be called multiple times so an average can be taken.
   133 */
   134 EXPORT_C void CTProfiler::MarkResultSetL()
   135     {   
   136     MarkResultSetAndSuspendL();
   137     StartTimer();
   138     }
   139 
   140 /**
   141 Records set current time. Unlike MarkResultSetL() the function doesn't 
   142 restart the timer at the end. The following operations will not be 
   143 included into benchmark mesuarment. To resume the profiling the user must 
   144 start the timer.
   145 @see StartTimer()
   146 @see MarkResultSetL() 
   147 Can be called multiple times so an average can be taken.
   148 */
   149 EXPORT_C void CTProfiler::MarkResultSetAndSuspendL()
   150     {   
   151     TUint32 res = StopTimer();
   152     iResults.InsertInUnsignedKeyOrderAllowRepeatsL(res);
   153     if(iStoreResultInTimingOrder)
   154         {
   155         iResultsTimingOrder.AppendL(res);
   156         }
   157     iDiff = 0;
   158     PROFILER_TEST(iResultsInitalised);
   159     }
   160 
   161 /**
   162 Frees all memory allocated by results capturing methods like MarkResultSetL().
   163 */
   164 EXPORT_C void CTProfiler::FreeResultsMemory()
   165     {
   166     iResults.Reset();
   167     iResultsTimingOrder.Reset();
   168     }
   169 
   170 /**
   171 Returns the trimmed mean of a set of results. i.e. Trims off the 20% smallest and the 20% largest of the data results.
   172 */
   173 EXPORT_C TUint32 CTProfiler::GetTrimedMean()
   174     {
   175     TInt64 total = 0;   
   176     if (iResults.Count() <= 50)
   177         {
   178         PROFILER_WARN_PRINTF2(_L("Not enough results for trimming - need more than 50, but got %d"), iResults.Count());
   179         }
   180     if (iResults.Count() == 0)      // If iResults is zero then do nothing
   181         {
   182         return 0;
   183         }
   184 
   185     TInt twentyPercentCount = iResults.Count()/5;
   186     for (TInt count = twentyPercentCount; count < iResults.Count()-twentyPercentCount; count++)
   187         {
   188         total += iResults[count];
   189         }
   190     return ((TUint32)(total/(iResults.Count()-(twentyPercentCount*2))));
   191     }
   192 
   193 EXPORT_C TInt CTProfiler::PercentageChange(TInt aFirstTime, TInt aSecondTime)
   194     {
   195     return ((aFirstTime - aSecondTime)*100) / aFirstTime;
   196     }
   197 
   198 /**
   199 Finds the maximum time taken
   200 */
   201 EXPORT_C TUint32 CTProfiler::TimeMax()
   202     {
   203     if (iResults.Count() == 0)
   204         {
   205         return 0;
   206         }
   207     TUint32 result = iResults[0];
   208     for(TInt i = 0; i < iResults.Count(); i++)
   209         {
   210         if(iResults[i] > result)
   211             result = iResults[i];
   212         }
   213     return result;
   214     }
   215 
   216 /**
   217 Finds the minimum time taken
   218 */  
   219 EXPORT_C TUint32 CTProfiler::TimeMin()
   220     {
   221     if (iResults.Count() == 0)
   222         {
   223         return 0;
   224         }
   225     TUint32 result = iResults[0];
   226     for(TInt i = 0; i < iResults.Count(); i++)
   227         {
   228         if(iResults[i] < result)
   229             result = iResults[i];
   230         }
   231     return result;
   232     }
   233 
   234 /**
   235 Reports analysis results
   236 
   237 @param aTestName is the name of the test case
   238 @param aRotation is the screen rotation being used in the test
   239 @param aSrcScreenMode is the source screen mode being used, 
   240 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   241 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   242 @param aIters is the number of iterations used in the test
   243 */
   244 EXPORT_C void CTProfiler::ResultsAnalysis(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
   245     {
   246     PROFILER_TEST(iResultsInitalised);
   247     TBuf<128> variation;
   248     variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode,aIters);
   249     TBuf<128> variationMax;
   250     variationMax.Format(KMaxTime, &variation);
   251     TBuf<128> variationMin;
   252     variationMin.Format(KMinTime, &variation);
   253     TBuf<128> variationTrimmedMean;
   254     variationTrimmedMean.Format(KTrimmedMean, &variation);
   255     
   256     SqlInsert(&aTestName, &variationTrimmedMean,    &KMicroSeconds,  GetTrimedMean());
   257     SqlInsert(&aTestName, &variationMax,            &KMicroSeconds,  TimeMax());
   258     SqlInsert(&aTestName, &variationMin,            &KMicroSeconds,  TimeMin());
   259     
   260     iResultsInitalised = EFalse;
   261     }
   262 
   263 /**
   264 Reports analysis results for pixel rates
   265 
   266 @param aTestName is the name of the test case
   267 @param aRotation is the screen rotation being used in the test
   268 @param aSrcScreenMode is the source screen mode being used, 
   269 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   270 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   271 @param aIters is the number of iterations used in the test
   272 @param aNumPixels is the number of pixels rendered
   273 */
   274 EXPORT_C void CTProfiler::ResultsAnalysisPixelRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
   275     {
   276     PROFILER_TEST(iResultsInitalised);
   277 
   278     TReal time = (TReal)iResults[0] / 1000000;
   279     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   280     
   281     TBuf<128> variation;
   282     variation.Format(KVariationPPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumPixelsPerIteration);
   283     TBuf<128> variationMax;
   284     variationMax.Format(KMaxTime, &variation);
   285     TBuf<128> variationMin;   
   286     variationMin.Format(KMinTime, &variation);
   287     
   288     SqlInsert(&aTestName, &variation,       &KPixelsPerSecond,  pixelRate);
   289     SqlInsert(&aTestName, &variationMax,    &KMicroSeconds,     TimeMax());
   290     SqlInsert(&aTestName, &variationMin,    &KMicroSeconds,     TimeMin());
   291     
   292     iResultsInitalised = EFalse;
   293     }
   294 
   295 /**
   296 Reports analysis results for character rates
   297 
   298 @param aTestName is the name of the test case
   299 @param aRotation is the screen rotation being used in the test
   300 @param aSrcScreenMode is the source screen mode being used, 
   301 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   302 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   303 @param aIters is the number of iterations used in the test
   304 @param aNumChars is the number of characters rendered
   305 */
   306 EXPORT_C void CTProfiler::ResultsAnalysisCharacterRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumCharsPerIteration)
   307     {
   308     PROFILER_TEST(iResultsInitalised);
   309     TReal time = (TReal)iResults[0] / 1000000;
   310     TInt32 characterRate = aNumCharsPerIteration*aIters/time;
   311     
   312     TBuf<128> variation;
   313     variation.Format(KVariationCPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumCharsPerIteration);
   314     TBuf<128> variationMax;
   315     variationMax.Format(KMaxTime, &variation);
   316     TBuf<128> variationMin;   
   317     variationMin.Format(KMinTime, &variation);
   318     
   319     SqlInsert(&aTestName, &variation,       &KCharacterRate,  characterRate);
   320     SqlInsert(&aTestName, &variationMax,    &KMicroSeconds,   TimeMax());
   321     SqlInsert(&aTestName, &variationMin,    &KMicroSeconds,   TimeMin());
   322     
   323     iResultsInitalised = EFalse;
   324     }
   325 
   326 /**
   327 Reports analysis results when there is one total result given the number of itertions
   328 This function should only be used if you cannot obtain the times for each iteration of 
   329 the test and ResultsAnalysis cannot be used.
   330 
   331 @param aTestName is the name of the test case
   332 @param aRotation is the screen rotation being used in the test
   333 @param aSrcScreenMode is the source screen mode being used, 
   334 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   335 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   336 @param aIters is the number of iterations used in the test
   337 */
   338 EXPORT_C void CTProfiler::ResultsAnalysisAverageByIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
   339     {
   340     PROFILER_TEST(iResultsInitalised);
   341     
   342     TUint32 result = iResults[0]/aIters;
   343     
   344     TBuf<128> variation;
   345     variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode,aIters);
   346     TBuf<128> variationMax;
   347     variationMax.Format(KMaxTime, &variation);
   348     TBuf<128> variationMin;
   349     variationMin.Format(KMinTime, &variation);  
   350 
   351     SqlInsert(&aTestName, &variation,       &KMicroSeconds,  result);
   352     SqlInsert(&aTestName, &variationMax,    &KMicroSeconds,  TimeMax());
   353     SqlInsert(&aTestName, &variationMin,    &KMicroSeconds,  TimeMin());
   354     
   355     iResultsInitalised = EFalse;
   356     }
   357 
   358 /**
   359  * Generate an SQL insert statement into the logs, intended for subsequent
   360  * extraction by a script to load into the database.
   361  * Inserts data fields for 
   362  * (sessionid, testname, testattribute, testunits, testresultvalue).
   363  * An example insertion:
   364  * <code>
   365  * SQL_UPLOAD_VERSION_0:insert into performance.testresultstable (sessionid, testname, testattribute, testunits, testresultvalue) values
   366  * SQL_UPLOAD_VERSION_0:('1136416860', 'GRAPHICS-UI-BENCH-S60-0009', 'Rot_0_SrcMode_0_DestMode_0_Iters_25', 'pixels/second', '394159');
   367  * </code>
   368  * 
   369  * @param aTestName Column testname
   370  * @param aTestAttribute Column testattribute
   371  * @param aTestUnit Column testunits
   372  * @param aTestResultValue Column testresultvalue
   373  */
   374 EXPORT_C void CTProfiler::SqlInsert(const TDesC* aTestName, const TDesC* aTestAttribute, const TDesC* aTestUnit, TInt32 aTestResultValue)
   375     {
   376     TBuf<200>scratchPad;
   377     /*
   378      * There is a 256 character limit on logging output, and a 7 vararg limit
   379      * on the macro we can use to issue printfs to the test framework.  Each
   380      * output line which has SQL in it needs to have a marker at the front so
   381      * that a script can reliably extract the SQL statements.  Hence we use
   382      * the following incremental strategy of getting our SQL statements output
   383      * into the logs.
   384      */
   385     scratchPad.Format(KSqlInsert);
   386     PROFILER_INFO_PRINTF2(_L("%S"), &scratchPad);
   387     scratchPad.Format(KSqlData, iSessionId, aTestName, aTestAttribute, aTestUnit, aTestResultValue); 
   388     PROFILER_INFO_PRINTF2(_L("%S"), &scratchPad);
   389     }
   390 
   391 /**
   392 Reports analysis results for frame rates
   393 
   394 @param aTestName is the name of the test case
   395 @param aRotation is the screen rotation being used in the test
   396 @param aSrcScreenMode is the source screen mode being used, 
   397 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   398 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   399 @param aIters is the number of iterations used in the test
   400 @param aNumPixels is the number of pixels rendered
   401 */
   402 EXPORT_C void CTProfiler::ResultsAnalysisFrameRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
   403     {
   404     PROFILER_TEST(iResultsInitalised);
   405     TReal time = (TReal)iResults[0] / 1000000;
   406     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   407     TInt32 frameRate = aIters / time;
   408     
   409     TBuf<128> variation;
   410     variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode, aIters);
   411     TBuf<128> variationMax;
   412     variationMax.Format(KMaxTime, &variation);
   413     TBuf<128> variationMin;   
   414     variationMin.Format(KMinTime, &variation);
   415     
   416     SqlInsert(&aTestName, &variation,       &KPixelsPerSecond,  pixelRate);
   417     SqlInsert(&aTestName, &variation,       &KFrameRate,        frameRate);
   418     SqlInsert(&aTestName, &variationMax,    &KMicroSeconds,     TimeMax());
   419     SqlInsert(&aTestName, &variationMin,    &KMicroSeconds,     TimeMin());
   420 
   421     iResultsInitalised = EFalse;
   422     }
   423 
   424 /**
   425 Reports analysis results for screen rotation rates
   426 
   427 @param aTestName is the name of the test case
   428 @param aRotation is the screen rotation being used in the test
   429 @param aSrcScreenMode is the source screen mode being used, 
   430 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   431 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   432 @param aIters is the number of iterations used in the test
   433 @param aNumPixels is the number of pixels rendered
   434 */
   435 EXPORT_C void CTProfiler::ResultsAnalysisScreenRotationRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
   436     {
   437     PROFILER_TEST(iResultsInitalised);
   438     TReal time = (TReal)iResults[0] / 1000000;
   439     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   440     TInt32 frameRate = aIters / time;
   441     
   442     TBuf<128> variation;
   443     variation.Format(KVariationPPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumPixelsPerIteration);
   444     TBuf<128> variationMax;
   445     variationMax.Format(KMaxTime, &variation);
   446     TBuf<128> variationMin;   
   447     variationMin.Format(KMinTime, &variation);
   448     
   449     SqlInsert(&aTestName, &variation,       &KPixelsPerSecond,  pixelRate);
   450     SqlInsert(&aTestName, &variation,       &KFrameRate,        frameRate);
   451     SqlInsert(&aTestName, &variationMax,    &KMicroSeconds,     TimeMax());
   452     SqlInsert(&aTestName, &variationMin,    &KMicroSeconds,     TimeMin());
   453     
   454     iResultsInitalised = EFalse;
   455     }
   456 
   457 /**
   458 Reports analysis results for Z Order Switching rates
   459 
   460 @param aTestName is the name of the test case
   461 @param aZorderSwitching is the z Order Switching being used in the test
   462 @param aSrcScreenMode is the source screen mode being used, 
   463 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   464 @param aIters is the number of iterations used in the test
   465 @param aNumPixels is the number of pixels rendered
   466 */
   467 EXPORT_C void CTProfiler::ResultsAnalysisZorderSwitchingRate(const TDesC & aTestName, TInt aZorderSwitching, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
   468     {
   469     PROFILER_TEST(iResultsInitalised);
   470     TReal time = (TReal)iResults[0] / 1000000;
   471     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   472     TInt32 frameRate = aIters / time;
   473     
   474     TBuf<128> variation;
   475     variation.Format(KVariationZOrder, aZorderSwitching, aSrcScreenMode, aDstScreenMode, aIters, aNumPixelsPerIteration);
   476     TBuf<128> variationMax;
   477     variationMax.Format(KMaxTime, &variation);
   478     TBuf<128> variationMin;   
   479     variationMin.Format(KMinTime, &variation);
   480     
   481     SqlInsert(&aTestName, &variation,       &KPixelsPerSecond,  pixelRate);
   482     SqlInsert(&aTestName, &variation,       &KFrameRate,        frameRate);
   483     SqlInsert(&aTestName, &variationMax,    &KMicroSeconds,     TimeMax());
   484     SqlInsert(&aTestName, &variationMin,    &KMicroSeconds,     TimeMin());
   485     
   486     iResultsInitalised = EFalse;
   487     }
   488 
   489 /**
   490 This function calclulates the mean without deleting any of the values from iResults
   491 */  
   492 EXPORT_C TUint32 CTProfiler::Mean()
   493     {
   494     TInt64 total = 0;   
   495     TInt count1 = iResults.Count();
   496     for (TInt count = 0; count < iResults.Count(); count++)
   497         {
   498         total += iResults[count];
   499         }
   500     return ((TUint32)(total/(iResults.Count())));   
   501     }
   502 
   503 
   504 /**
   505 Reports analysis of results when there are more then one values by calculating the average based on value of iResult.count().
   506 
   507 @param aTestName is the name of the test case
   508 @param aRotation is the screen rotation being used in the test
   509 @param aSrcScreenMode is the source screen mode being used, 
   510 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   511 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   512 @param aIters is the number of iterations used in the test
   513 */
   514 EXPORT_C void CTProfiler::ResultsAnalysisAverageByNumberOfIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode,TInt aIters)
   515     {
   516     PROFILER_TEST(iResultsInitalised);
   517     TBuf<128> variation;
   518     variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode, aIters);
   519     TBuf<128> variationMean;
   520     variationMean.Format(KMean, &variation);   
   521     TBuf<128> variationMax;
   522     variationMax.Format(KMaxTime, &variation);
   523     TBuf<128> variationMin;   
   524     variationMin.Format(KMinTime, &variation);
   525  
   526     SqlInsert(&aTestName, &variationMean, &KMicroSeconds,  Mean());
   527     SqlInsert(&aTestName, &variationMax,  &KMicroSeconds,  TimeMax());
   528     SqlInsert(&aTestName, &variationMin,  &KMicroSeconds,  TimeMin());
   529     
   530     iResultsInitalised = EFalse;
   531     }
   532 
   533 /**
   534 Output all results.
   535 */
   536 EXPORT_C void CTProfiler::ShowResultArrayInTimingOrder()
   537     {
   538     for(TInt i=0; i < iResultsTimingOrder.Count(); i++)
   539         {
   540         PROFILER_INFO_PRINTF3(_L("iResultsTimingOrder[%4d]: %8d"),i, iResultsTimingOrder[i]);
   541         }
   542     }
   543 
   544 /**
   545  @param aStoreResultInTimingOrder Signify whether the results should be stored as they coming   
   546  */
   547 EXPORT_C void CTProfiler::SetStoreResultInTimingOrder(TBool aStoreResultInTimingOrder)
   548     {
   549     iStoreResultInTimingOrder = aStoreResultInTimingOrder;
   550     }
   551 
   552 /**
   553 Reports analysis results for glyph rates
   554 
   555 @param aTestName is the name of the test case
   556 @param aRotation is the screen rotation being used in the test
   557 @param aSrcScreenMode is the source screen mode being used, 
   558 i.e. for bitmap display conversion the source and destinations bitmaps maybe different
   559 @param aDstScreenMode is the destination screen mode (usually the display screen mode)
   560 @param aIters is the number of iterations used in the test
   561 @param aNumGlyphs is the number of glyphs used per iteration
   562 */
   563 
   564 EXPORT_C void CTProfiler::ResultsAnalysisGlyphRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumGlyphsPerIteration)
   565     {
   566     PROFILER_TEST(iResultsInitalised);
   567     TReal time = (iResults.Count() > 0) ? (TReal)iResults[0] / 1000000 : 0;
   568     TInt32 glyphRate = aNumGlyphsPerIteration*aIters/time;
   569 
   570     TBuf<128> variation;
   571     variation.Format(KVariationCPI, aRotation, aSrcScreenMode, aDstScreenMode, aIters, aNumGlyphsPerIteration);
   572     TBuf<128> variationMax;
   573     variationMax.Format(KMaxTime, &variation);
   574     TBuf<128> variationMin;
   575     variationMin.Format(KMinTime, &variation);
   576 
   577     SqlInsert(&aTestName, &variation,       &KGlyphRate,  glyphRate);
   578     SqlInsert(&aTestName, &variationMax,    &KMicroSeconds,  TimeMax());
   579     SqlInsert(&aTestName, &variationMin,    &KMicroSeconds,  TimeMin());
   580 
   581     iResultsInitalised = EFalse;
   582     }
   583