graphicstest/graphicstestharness/src/tprofiler.cpp
branchRCL_3
changeset 163 bbf46f59e123
parent 0 5d03bc08d59c
child 164 25ffed67c7ef
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18  @test
    18  @test
    19  @internalComponent - Internal Symbian test code 
    19  @internalComponent - Internal Symbian test code 
    20 */
    20 */
    21 
    21 
    22 #include <test/TestExecuteStepBase.h>
    22 #include <test/TestExecuteStepBase.h>
       
    23 #include <e32math.h>
    23 #include <hal.h>
    24 #include <hal.h>
    24 #include "tprofiler.h"
    25 #include "tprofiler.h"
    25 
    26 
    26 
    27 
    27 #define PROFILER_TEST(a)  (iTestStep.testBooleanTrue((a), (TText8*)__FILE__, __LINE__)) 
    28 #define PROFILER_TEST(a)  (iTestStep.testBooleanTrue((a), (TText8*)__FILE__, __LINE__)) 
    33 #define PROFILER_INFO_PRINTF4(p1, p2, p3, p4)                iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
    34 #define PROFILER_INFO_PRINTF4(p1, p2, p3, p4)                iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4))
    34 #define PROFILER_INFO_PRINTF5(p1, p2, p3, p4, p5)            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
    35 #define PROFILER_INFO_PRINTF5(p1, p2, p3, p4, p5)            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5))
    35 #define PROFILER_INFO_PRINTF6(p1, p2, p3, p4, p5, p6)        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
    36 #define PROFILER_INFO_PRINTF6(p1, p2, p3, p4, p5, p6)        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6))
    36 #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))
    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))
    37 
    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 
    38 #define PROFILER_ERR_PRINTF1(p1)                             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1)) 
    47 #define PROFILER_ERR_PRINTF1(p1)                             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1)) 
    39 #define PROFILER_ERR_PRINTF2(p1, p2)                         iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)) 
    48 #define PROFILER_ERR_PRINTF2(p1, p2)                         iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)) 
    40 #define PROFILER_ERR_PRINTF3(p1, p2, p3)                     iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)) ;
    49 #define PROFILER_ERR_PRINTF3(p1, p2, p3)                     iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)) ;
    41 #define PROFILER_ERR_PRINTF4(p1, p2, p3, p4)                 iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4)) 
    50 #define PROFILER_ERR_PRINTF4(p1, p2, p3, p4)                 iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4)) 
    42 #define PROFILER_ERR_PRINTF5(p1, p2, p3, p4, p5)             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5)) 
    51 #define PROFILER_ERR_PRINTF5(p1, p2, p3, p4, p5)             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5)) 
    50     }
    59     }
    51 
    60 
    52 EXPORT_C CTProfiler::~CTProfiler()
    61 EXPORT_C CTProfiler::~CTProfiler()
    53     {   
    62     {   
    54     iResults.Reset();
    63     iResults.Reset();
       
    64     iResultsTimingOrder.Reset();
    55     }
    65     }
    56 
    66 
    57 EXPORT_C CTProfiler* CTProfiler::NewL(CTestStep& aTestStep)
    67 EXPORT_C CTProfiler* CTProfiler::NewL(CTestStep& aTestStep)
    58     {
    68     {
    59     CTProfiler* profiler = new (ELeave) CTProfiler(aTestStep);
    69     CTProfiler* profiler = new (ELeave) CTProfiler(aTestStep);
    95     {
   105     {
    96     PROFILER_TEST(!iResultsInitalised);
   106     PROFILER_TEST(!iResultsInitalised);
    97     iResultsInitalised = ETrue;
   107     iResultsInitalised = ETrue;
    98     iDiff = 0;
   108     iDiff = 0;
    99     iResults.Reset();
   109     iResults.Reset();
   100     
   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);
   101     StartTimer();
   128     StartTimer();
   102     }
   129     }
   103 
   130 
   104 /**
   131 /**
   105 Records set current time. Can be called multiple times so an average can be taken.
   132 Records set current time. Can be called multiple times so an average can be taken.
   106 */
   133 */
   107 EXPORT_C void CTProfiler::MarkResultSetL()
   134 EXPORT_C void CTProfiler::MarkResultSetL()
   108     {   
   135     {   
   109     iResults.InsertInUnsignedKeyOrderAllowRepeatsL((TUint32)StopTimer());
   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         }
   110     iDiff = 0;
   157     iDiff = 0;
   111     PROFILER_TEST(iResultsInitalised);
   158     PROFILER_TEST(iResultsInitalised);
   112     StartTimer();
       
   113     }
   159     }
   114 
   160 
   115 /**
   161 /**
   116 Frees all memory allocated by results capturing methods like MarkResultSetL().
   162 Frees all memory allocated by results capturing methods like MarkResultSetL().
   117 */
   163 */
   118 EXPORT_C void CTProfiler::FreeResultsMemory()
   164 EXPORT_C void CTProfiler::FreeResultsMemory()
   119     {
   165     {
   120     iResults.Reset();
   166     iResults.Reset();
       
   167     iResultsTimingOrder.Reset();
   121     }
   168     }
   122 
   169 
   123 /**
   170 /**
   124 Returns the trimmed mean of a set of results. i.e. Trims off the 20% smallest and the 20% largest of the data results.
   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.
   125 */
   172 */
   126 EXPORT_C TUint32 CTProfiler::GetTrimedMean()
   173 EXPORT_C TUint32 CTProfiler::GetTrimedMean()
   127     {
   174     {
   128     TInt64 total = 0;   
   175     TInt64 total = 0;   
   129     if (iResults.Count() <= 50)
   176     if (iResults.Count() <= 50)
   130         PROFILER_ERR_PRINTF2(_L("Not enough results for trimming - need more than 50, but got %d"), iResults.Count());
   177         {
       
   178         PROFILER_WARN_PRINTF2(_L("Not enough results for trimming - need more than 50, but got %d"), iResults.Count());
       
   179         }
   131     if (iResults.Count() == 0)      // If iResults is zero then do nothing
   180     if (iResults.Count() == 0)      // If iResults is zero then do nothing
   132         {
   181         {
   133         return 0;
   182         return 0;
   134         }
   183         }
   135     PROFILER_TEST(iResults.Count() > 50); //Ensure we have an ability to remove some results in trimming
   184 
   136     TInt twentyPercentCount = iResults.Count()/5;
   185     TInt twentyPercentCount = iResults.Count()/5;
   137     for (TInt count = twentyPercentCount; count < iResults.Count()-twentyPercentCount; count++)
   186     for (TInt count = twentyPercentCount; count < iResults.Count()-twentyPercentCount; count++)
   138         {
   187         {
   139         total += iResults[count];
   188         total += iResults[count];
   140         }
   189         }
   147     }
   196     }
   148 
   197 
   149 /**
   198 /**
   150 Finds the maximum time taken
   199 Finds the maximum time taken
   151 */
   200 */
   152 TUint32 CTProfiler::TimeMax()
   201 EXPORT_C TUint32 CTProfiler::TimeMax()
   153     {
   202     {
   154     if (iResults.Count() == 0)
   203     if (iResults.Count() == 0)
   155         {
   204         {
   156         return 0;
   205         return 0;
   157         }
   206         }
   165     }
   214     }
   166 
   215 
   167 /**
   216 /**
   168 Finds the minimum time taken
   217 Finds the minimum time taken
   169 */  
   218 */  
   170 TUint32 CTProfiler::TimeMin()
   219 EXPORT_C TUint32 CTProfiler::TimeMin()
   171     {
   220     {
   172     if (iResults.Count() == 0)
   221     if (iResults.Count() == 0)
   173         {
   222         {
   174         return 0;
   223         return 0;
   175         }
   224         }
   193 @param aIters is the number of iterations used in the test
   242 @param aIters is the number of iterations used in the test
   194 */
   243 */
   195 EXPORT_C void CTProfiler::ResultsAnalysis(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
   244 EXPORT_C void CTProfiler::ResultsAnalysis(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
   196     {
   245     {
   197     PROFILER_TEST(iResultsInitalised);
   246     PROFILER_TEST(iResultsInitalised);
   198 
   247     TBuf<128> variation;
   199     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  us"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters,  GetTrimedMean());
   248     variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode,aIters);
   200     PROFILER_INFO_PRINTF3(_L("Max:   %i  Min:    %i  "), TimeMax(), TimeMin());
   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     
   201     iResultsInitalised = EFalse;
   260     iResultsInitalised = EFalse;
   202     }
   261     }
   203 
   262 
   204 /**
   263 /**
   205 Reports analysis results for pixel rates
   264 Reports analysis results for pixel rates
   213 @param aNumPixels is the number of pixels rendered
   272 @param aNumPixels is the number of pixels rendered
   214 */
   273 */
   215 EXPORT_C void CTProfiler::ResultsAnalysisPixelRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
   274 EXPORT_C void CTProfiler::ResultsAnalysisPixelRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumPixelsPerIteration)
   216     {
   275     {
   217     PROFILER_TEST(iResultsInitalised);
   276     PROFILER_TEST(iResultsInitalised);
       
   277 
   218     TReal time = (TReal)iResults[0] / 1000000;
   278     TReal time = (TReal)iResults[0] / 1000000;
   219     TInt32 pixelRate = aNumPixelsPerIteration*aIters/time;
   279     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   220     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  pixels/second"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters, pixelRate);
   280     
   221     PROFILER_INFO_PRINTF3(_L("Max:   %i  Min:    %i  "), TimeMax(), TimeMin());
   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     
   222     iResultsInitalised = EFalse;
   292     iResultsInitalised = EFalse;
   223     }
   293     }
   224 
   294 
   225 /**
   295 /**
   226 Reports analysis results for character rates
   296 Reports analysis results for character rates
   236 EXPORT_C void CTProfiler::ResultsAnalysisCharacterRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumCharsPerIteration)
   306 EXPORT_C void CTProfiler::ResultsAnalysisCharacterRate(const TDesC & aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters, TInt aNumCharsPerIteration)
   237     {
   307     {
   238     PROFILER_TEST(iResultsInitalised);
   308     PROFILER_TEST(iResultsInitalised);
   239     TReal time = (TReal)iResults[0] / 1000000;
   309     TReal time = (TReal)iResults[0] / 1000000;
   240     TInt32 characterRate = aNumCharsPerIteration*aIters/time;
   310     TInt32 characterRate = aNumCharsPerIteration*aIters/time;
   241     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  characters/second"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters, characterRate);
   311     
   242     PROFILER_INFO_PRINTF3(_L("Max:   %i  Min:    %i  "), TimeMax(), TimeMin());
   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     
   243     iResultsInitalised = EFalse;
   323     iResultsInitalised = EFalse;
   244     }
   324     }
   245 
   325 
   246 /**
   326 /**
   247 Reports analysis results when there is one total result given the number of itertions
   327 Reports analysis results when there is one total result given the number of itertions
   257 */
   337 */
   258 EXPORT_C void CTProfiler::ResultsAnalysisAverageByIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
   338 EXPORT_C void CTProfiler::ResultsAnalysisAverageByIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode, TInt aIters)
   259     {
   339     {
   260     PROFILER_TEST(iResultsInitalised);
   340     PROFILER_TEST(iResultsInitalised);
   261     
   341     
   262     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  us"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters,  iResults[0]/aIters);
   342     TUint32 result = iResults[0]/aIters;
   263     PROFILER_INFO_PRINTF3(_L("Max:   %i  Min:    %i  "), TimeMax(), TimeMin());
   343     
   264     iResultsInitalised = EFalse;
   344     TBuf<128> variation;
   265     }
   345     variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode,aIters);
   266     
   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     }
   267 
   390 
   268 /**
   391 /**
   269 Reports analysis results for frame rates
   392 Reports analysis results for frame rates
   270 
   393 
   271 @param aTestName is the name of the test case
   394 @param aTestName is the name of the test case
   280     {
   403     {
   281     PROFILER_TEST(iResultsInitalised);
   404     PROFILER_TEST(iResultsInitalised);
   282     TReal time = (TReal)iResults[0] / 1000000;
   405     TReal time = (TReal)iResults[0] / 1000000;
   283     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   406     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   284     TInt32 frameRate = aIters / time;
   407     TInt32 frameRate = aIters / time;
   285     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  pixels/second"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters, pixelRate);
   408     
   286     PROFILER_INFO_PRINTF4(_L("Max:   %i  Min:    %i  Framerate:  %i  frames/second"), TimeMax(), TimeMin(), frameRate);
   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 
   287     iResultsInitalised = EFalse;
   421     iResultsInitalised = EFalse;
   288     }
   422     }
   289 
   423 
   290 /**
   424 /**
   291 Reports analysis results for screen rotation rates
   425 Reports analysis results for screen rotation rates
   302     {
   436     {
   303     PROFILER_TEST(iResultsInitalised);
   437     PROFILER_TEST(iResultsInitalised);
   304     TReal time = (TReal)iResults[0] / 1000000;
   438     TReal time = (TReal)iResults[0] / 1000000;
   305     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   439     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   306     TInt32 frameRate = aIters / time;
   440     TInt32 frameRate = aIters / time;
   307     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  pixels/second"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters, pixelRate);
   441     
   308     PROFILER_INFO_PRINTF4(_L("Max:   %i  Min:    %i  Framerate:  %i  frames/second"), TimeMax(), TimeMin(), frameRate);
   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     
   309     iResultsInitalised = EFalse;
   454     iResultsInitalised = EFalse;
   310     }
   455     }
   311 
   456 
   312 /**
   457 /**
   313 Reports analysis results for Z Order Switching rates
   458 Reports analysis results for Z Order Switching rates
   323     {
   468     {
   324     PROFILER_TEST(iResultsInitalised);
   469     PROFILER_TEST(iResultsInitalised);
   325     TReal time = (TReal)iResults[0] / 1000000;
   470     TReal time = (TReal)iResults[0] / 1000000;
   326     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   471     TInt32 pixelRate = aNumPixelsPerIteration * aIters / time;
   327     TInt32 frameRate = aIters / time;
   472     TInt32 frameRate = aIters / time;
   328     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  pixels/second"), &aTestName, aZorderSwitching, aSrcScreenMode, aDstScreenMode, aIters, pixelRate);
   473     
   329     PROFILER_INFO_PRINTF4(_L("Max:   %i  Min:    %i  Framerate:  %i  frames/second"), TimeMax(), TimeMin(), frameRate);
   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     
   330     iResultsInitalised = EFalse;
   486     iResultsInitalised = EFalse;
   331     }
   487     }
   332 
   488 
   333 /**
   489 /**
   334 This function calclulates the mean without deleting any of the values from iResults
   490 This function calclulates the mean without deleting any of the values from iResults
   356 @param aIters is the number of iterations used in the test
   512 @param aIters is the number of iterations used in the test
   357 */
   513 */
   358 EXPORT_C void CTProfiler::ResultsAnalysisAverageByNumberOfIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode,TInt aIters)
   514 EXPORT_C void CTProfiler::ResultsAnalysisAverageByNumberOfIterations(const TDesC& aTestName, TInt aRotation, TInt aSrcScreenMode, TInt aDstScreenMode,TInt aIters)
   359     {
   515     {
   360     PROFILER_TEST(iResultsInitalised);
   516     PROFILER_TEST(iResultsInitalised);
   361     
   517     TBuf<128> variation;
   362     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  us"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters,  Mean());
   518     variation.Format(KVariation, aRotation, aSrcScreenMode, aDstScreenMode, aIters);
   363     PROFILER_INFO_PRINTF3(_L("Max:   %i  Min:    %i  "), TimeMax(), TimeMin());  
   519     TBuf<128> variationMean;
   364     iResultsInitalised = EFalse;
   520     variationMean.Format(KMean, &variation);   
   365     }
   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