camerauis/cameraapp/generic/inc/cameracontroller/camperformancelogger.h
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CAM_PERFORMANCELOGGER_H
       
    21 #define CAM_PERFORMANCELOGGER_H
       
    22 
       
    23 
       
    24 #include "camcameracontrollerflags.hrh"
       
    25 
       
    26 
       
    27 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER
       
    28 // ===========================================================================
       
    29 _LIT( KCamPerformanceItemFormat, "%s duration: %d \n");
       
    30 
       
    31 class TCamPerformanceItem
       
    32   {
       
    33   public:
       
    34     TCamPerformanceItem( TCamCameraRequestId aId )
       
    35       : iId( aId ), iStart( Time64() ), iStop( iStart ) {};
       
    36 
       
    37     TCamPerformanceItem( const TCamPerformanceItem& aOther )
       
    38       : iId( aOther.iId ), iStart( aOther.iStart ), iStop( aOther.iStop ) {};
       
    39 
       
    40     void Start() { iStart = Time64(); iStop = iStart; };
       
    41     void Stop()  { iStop  = Time64();                 };
       
    42   
       
    43     TInt64 Time64() const
       
    44       {
       
    45       TTime time;
       
    46       time.HomeTime();
       
    47       return time.Int64();
       
    48       };
       
    49 
       
    50     TInt Duration() const
       
    51       {
       
    52       return (TInt)(iStop - iStart);
       
    53       };
       
    54 
       
    55     const TCamCameraRequestId iId;
       
    56     TInt64                    iStart;
       
    57     TInt64                    iStop;
       
    58   };
       
    59 
       
    60 
       
    61 
       
    62 
       
    63 class CCamPerformanceLogger : public CBase
       
    64   {
       
    65   public:
       
    66     CCamPerformanceLogger() {};
       
    67     ~CCamPerformanceLogger() 
       
    68       { 
       
    69       iData.Reset();
       
    70       iData.Close(); 
       
    71       };
       
    72   
       
    73     void Requested( const TCamCameraRequestId& aRequest )
       
    74       {
       
    75       TInt error = iData.Append( TCamPerformanceItem( aRequest ) );
       
    76 
       
    77       if( KErrNone != error )
       
    78         {
       
    79         // Ignored
       
    80         }
       
    81       };
       
    82 
       
    83     void Completed( const TCamCameraRequestId& aRequest )
       
    84       {
       
    85       // Set the end time for last performance item
       
    86       // found with this id.
       
    87       for( TInt i = iData.Count() - 1; i >= 0; i-- )
       
    88         {
       
    89         if( aRequest == iData[i].iId )
       
    90           {
       
    91           iData[i].Stop();
       
    92           return;
       
    93           }          
       
    94         }
       
    95       /// Ignore error if not found
       
    96       };
       
    97 
       
    98     TInt InfoSizeEstimate() const
       
    99       {
       
   100       return 50 * iData.Count();
       
   101       }
       
   102 
       
   103     void InfoText( TDes& aDes ) const
       
   104       {
       
   105       TInt count = iData.Count();
       
   106       for( TInt i = 0; i < count; i++ )
       
   107         {
       
   108         const TCamPerformanceItem& item = iData[i];
       
   109         // ECamRequestNone used to mark sequence start and end.
       
   110         if( item.iId >= ECamRequestNone && item.iId < ECamRequestLast )
       
   111           {
       
   112           aDes.AppendFormat( KCamPerformanceItemFormat, KCamRequestNames[item.iId], item.Duration() );
       
   113           }
       
   114         } 
       
   115       }
       
   116 
       
   117   private:
       
   118     RArray<TCamPerformanceItem> iData;
       
   119   };
       
   120 // ===========================================================================
       
   121 #endif // CAMERAAPP_PERFORMANCE_CONTROLLER
       
   122 
       
   123 #endif // CAM_PERFORMANCELOGGER_H