graphicstest/graphicstestharness/src/tprofiler.cpp
changeset 36 01a6848ebfd7
parent 0 5d03bc08d59c
child 69 3365349494cc
equal deleted inserted replaced
0:5d03bc08d59c 36:01a6848ebfd7
    33 #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))
    34 #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))
    35 #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))
    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))
    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 
    37 
       
    38 #define PROFILER_WARN_PRINTF1(p1)                            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1))
       
    39 #define PROFILER_WARN_PRINTF2(p1, p2)                        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2))
       
    40 #define PROFILER_WARN_PRINTF3(p1, p2, p3)                    iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3))
       
    41 #define PROFILER_WARN_PRINTF4(p1, p2, p3, p4)                iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4))
       
    42 #define PROFILER_WARN_PRINTF5(p1, p2, p3, p4, p5)            iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5))
       
    43 #define PROFILER_WARN_PRINTF6(p1, p2, p3, p4, p5, p6)        iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6))
       
    44 #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))
       
    45 
    38 #define PROFILER_ERR_PRINTF1(p1)                             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1)) 
    46 #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)) 
    47 #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)) ;
    48 #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)) 
    49 #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)) 
    50 #define PROFILER_ERR_PRINTF5(p1, p2, p3, p4, p5)             iTestStep.Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5)) 
    50     }
    58     }
    51 
    59 
    52 EXPORT_C CTProfiler::~CTProfiler()
    60 EXPORT_C CTProfiler::~CTProfiler()
    53     {   
    61     {   
    54     iResults.Reset();
    62     iResults.Reset();
       
    63     iResultsTimingOrder.Reset();
    55     }
    64     }
    56 
    65 
    57 EXPORT_C CTProfiler* CTProfiler::NewL(CTestStep& aTestStep)
    66 EXPORT_C CTProfiler* CTProfiler::NewL(CTestStep& aTestStep)
    58     {
    67     {
    59     CTProfiler* profiler = new (ELeave) CTProfiler(aTestStep);
    68     CTProfiler* profiler = new (ELeave) CTProfiler(aTestStep);
    95     {
   104     {
    96     PROFILER_TEST(!iResultsInitalised);
   105     PROFILER_TEST(!iResultsInitalised);
    97     iResultsInitalised = ETrue;
   106     iResultsInitalised = ETrue;
    98     iDiff = 0;
   107     iDiff = 0;
    99     iResults.Reset();
   108     iResults.Reset();
       
   109     iResultsTimingOrder.Reset();
   100     
   110     
   101     StartTimer();
   111     StartTimer();
   102     }
   112     }
   103 
   113 
   104 /**
   114 /**
   105 Records set current time. Can be called multiple times so an average can be taken.
   115 Records set current time. Can be called multiple times so an average can be taken.
   106 */
   116 */
   107 EXPORT_C void CTProfiler::MarkResultSetL()
   117 EXPORT_C void CTProfiler::MarkResultSetL()
   108     {   
   118     {   
   109     iResults.InsertInUnsignedKeyOrderAllowRepeatsL((TUint32)StopTimer());
   119     TUint32 res = (TUint32)StopTimer();
       
   120     iResults.InsertInUnsignedKeyOrderAllowRepeatsL(res);
       
   121     if(iStoreResultInTimingOrder)
       
   122         {
       
   123         iResultsTimingOrder.AppendL(res);
       
   124         }
   110     iDiff = 0;
   125     iDiff = 0;
   111     PROFILER_TEST(iResultsInitalised);
   126     PROFILER_TEST(iResultsInitalised);
   112     StartTimer();
   127     StartTimer();
   113     }
   128     }
   114 
   129 
   115 /**
   130 /**
       
   131 Records set current time. Alike MarkResultSetL() the function doesn't 
       
   132 restart the timer at the end. The following operations will not be 
       
   133 included into benchmark mesuarment. To resume the profiling the user must 
       
   134 start the timer.
       
   135 @see StartTimer()
       
   136 @see MarkResultSetL() 
       
   137 Can be called multiple times so an average can be taken.
       
   138 */
       
   139 EXPORT_C void CTProfiler::MarkResultSetAndSuspendL()
       
   140     {   
       
   141     TUint32 res = StopTimer();
       
   142     iResults.InsertInUnsignedKeyOrderAllowRepeatsL(res);
       
   143     if(iStoreResultInTimingOrder)
       
   144         {
       
   145         iResultsTimingOrder.AppendL(res);
       
   146         }
       
   147     iDiff = 0;
       
   148     PROFILER_TEST(iResultsInitalised);
       
   149     }
       
   150 
       
   151 /**
   116 Frees all memory allocated by results capturing methods like MarkResultSetL().
   152 Frees all memory allocated by results capturing methods like MarkResultSetL().
   117 */
   153 */
   118 EXPORT_C void CTProfiler::FreeResultsMemory()
   154 EXPORT_C void CTProfiler::FreeResultsMemory()
   119     {
   155     {
   120     iResults.Reset();
   156     iResults.Reset();
       
   157     iResultsTimingOrder.Reset();
   121     }
   158     }
   122 
   159 
   123 /**
   160 /**
   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.
   161 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 */
   162 */
   126 EXPORT_C TUint32 CTProfiler::GetTrimedMean()
   163 EXPORT_C TUint32 CTProfiler::GetTrimedMean()
   127     {
   164     {
   128     TInt64 total = 0;   
   165     TInt64 total = 0;   
   129     if (iResults.Count() <= 50)
   166     if (iResults.Count() <= 50)
   130         PROFILER_ERR_PRINTF2(_L("Not enough results for trimming - need more than 50, but got %d"), iResults.Count());
   167         {
       
   168         PROFILER_WARN_PRINTF2(_L("Not enough results for trimming - need more than 50, but got %d"), iResults.Count());
       
   169         }
   131     if (iResults.Count() == 0)      // If iResults is zero then do nothing
   170     if (iResults.Count() == 0)      // If iResults is zero then do nothing
   132         {
   171         {
   133         return 0;
   172         return 0;
   134         }
   173         }
   135     PROFILER_TEST(iResults.Count() > 50); //Ensure we have an ability to remove some results in trimming
   174 
   136     TInt twentyPercentCount = iResults.Count()/5;
   175     TInt twentyPercentCount = iResults.Count()/5;
   137     for (TInt count = twentyPercentCount; count < iResults.Count()-twentyPercentCount; count++)
   176     for (TInt count = twentyPercentCount; count < iResults.Count()-twentyPercentCount; count++)
   138         {
   177         {
   139         total += iResults[count];
   178         total += iResults[count];
   140         }
   179         }
   147     }
   186     }
   148 
   187 
   149 /**
   188 /**
   150 Finds the maximum time taken
   189 Finds the maximum time taken
   151 */
   190 */
   152 TUint32 CTProfiler::TimeMax()
   191 EXPORT_C TUint32 CTProfiler::TimeMax()
   153     {
   192     {
   154     if (iResults.Count() == 0)
   193     if (iResults.Count() == 0)
   155         {
   194         {
   156         return 0;
   195         return 0;
   157         }
   196         }
   165     }
   204     }
   166 
   205 
   167 /**
   206 /**
   168 Finds the minimum time taken
   207 Finds the minimum time taken
   169 */  
   208 */  
   170 TUint32 CTProfiler::TimeMin()
   209 EXPORT_C TUint32 CTProfiler::TimeMin()
   171     {
   210     {
   172     if (iResults.Count() == 0)
   211     if (iResults.Count() == 0)
   173         {
   212         {
   174         return 0;
   213         return 0;
   175         }
   214         }
   361     
   400     
   362     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  us"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters,  Mean());
   401     PROFILER_INFO_PRINTF7(_L("TID:   %S  Rot:    %i  SrcMode:    %i  DestMode:   %i  Iters: %i   TrimmedMean:    %i  us"), &aTestName, aRotation, aSrcScreenMode, aDstScreenMode, aIters,  Mean());
   363     PROFILER_INFO_PRINTF3(_L("Max:   %i  Min:    %i  "), TimeMax(), TimeMin());  
   402     PROFILER_INFO_PRINTF3(_L("Max:   %i  Min:    %i  "), TimeMax(), TimeMin());  
   364     iResultsInitalised = EFalse;
   403     iResultsInitalised = EFalse;
   365     }
   404     }
       
   405 
       
   406 /**
       
   407 Output all results.
       
   408 */
       
   409 EXPORT_C void CTProfiler::ShowResultArrayInTimingOrder()
       
   410     {
       
   411     for(TInt i=0; i < iResultsTimingOrder.Count(); i++)
       
   412         {
       
   413         PROFILER_INFO_PRINTF3(_L("iResultsTimingOrder[%4d]: %8d"),i, iResultsTimingOrder[i]);
       
   414         }
       
   415     }
       
   416 
       
   417 /**
       
   418  @param aStoreResultInTimingOrder Signify whether the results should be stored as they coming   
       
   419  */
       
   420 EXPORT_C void CTProfiler::SetStoreResultInTimingOrder(TBool aStoreResultInTimingOrder)
       
   421     {
       
   422     iStoreResultInTimingOrder = aStoreResultInTimingOrder;
       
   423     }