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