khronosfws/openmax_al/inc/profileutilmacro.h
branchRCL_3
changeset 20 0ac9a5310753
parent 19 095bea5f582e
child 21 999b2818a0eb
equal deleted inserted replaced
19:095bea5f582e 20:0ac9a5310753
     1 /*
       
     2 * Copyright (c) 2009 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:  Internal Header to define Performance Profiling macros.
       
    15 *               The MACROS can be defined in the MMP file to enable profiling.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef PROFILEUTILMACRO_H
       
    20 #define PROFILEUTILMACRO_H
       
    21 /*
       
    22 // MACROS to be defined to use profiling
       
    23 PROFILE_TIME
       
    24 PROFILE_RAM_USAGE
       
    25 PROFILE_HEAP_USAGE
       
    26 PRINT_TO_CONSOLE_TIME_DIFF
       
    27 PRINT_TO_CONSOLE_RAM_DIFF
       
    28 PRINT_TO_CONSOLE_HEAP_DIFF
       
    29 */
       
    30 
       
    31 #if defined(PROFILE_TIME) || defined(PROFILE_RAM_USAGE) || defined(PROFILE_HEAP_USAGE)
       
    32 #include <e32debug.h>
       
    33 #include <hal.h>
       
    34 #endif
       
    35 
       
    36 #ifdef PROFILE_TIME
       
    37 #define TAG_TIME_PROFILING_BEGIN \
       
    38     TTime beginProfilingTime; \
       
    39     beginProfilingTime.HomeTime()
       
    40 
       
    41 #define TAG_TIME_PROFILING_BEGIN_NO_VAR_DEF \
       
    42     beginProfilingTime.HomeTime()
       
    43 
       
    44 #define TAG_TIME_PROFILING_END \
       
    45     TTime endProfilingTime; \
       
    46     endProfilingTime.HomeTime(); \
       
    47     TTimeIntervalMicroSeconds diffInMicroSecs = endProfilingTime.MicroSecondsFrom(beginProfilingTime)
       
    48 
       
    49 #define TAG_TIME_PROFILING_END_NO_VAR_DEF \
       
    50     endProfilingTime.HomeTime(); \
       
    51     diffInMicroSecs = endProfilingTime.MicroSecondsFrom(beginProfilingTime)
       
    52 
       
    53 #define PRINT_TO_CONSOLE_TIME_DIFF \
       
    54     RDebug::Printf("VPROFILEDAT: %s : Time taken[%u]microseconds ", __PRETTY_FUNCTION__, diffInMicroSecs.Int64())
       
    55 
       
    56 #define PRINT_TO_CONSOLE_HOME_TIME \
       
    57     TTime homeTime; \
       
    58     homeTime.HomeTime(); \
       
    59     RDebug::Printf("VPROFILEDAT: %s : Home Time [%u]microseconds ", __PRETTY_FUNCTION__, homeTime.Int64())
       
    60 
       
    61 #define PRINT_TO_CONSOLE_HOME_TIME_NO_VAR_DEF \
       
    62     homeTime.HomeTime(); \
       
    63     RDebug::Printf("VPROFILEDAT: %s : Home Time [%u]microseconds ", __PRETTY_FUNCTION__, homeTime.Int64())
       
    64 
       
    65 #else /* Empty macros */
       
    66 #define TAG_TIME_PROFILING_BEGIN
       
    67 #define TAG_TIME_PROFILING_BEGIN_NO_VAR_DEF
       
    68 #define TAG_TIME_PROFILING_END
       
    69 #define TAG_TIME_PROFILING_END_NO_VAR_DEF
       
    70 #define PRINT_TO_CONSOLE_TIME_DIFF
       
    71 #define PRINT_TO_CONSOLE_HOME_TIME
       
    72 #define PRINT_TO_CONSOLE_HOME_TIME_NO_VAR_DEF
       
    73 #endif /*PROFILE_TIME*/
       
    74 
       
    75 #ifdef PROFILE_RAM_USAGE
       
    76 #define TAG_RAM_PROFILING_BEGIN \
       
    77     TInt beginProfilingRAM; \
       
    78     TInt err1 = HAL::Get(HALData::EMemoryRAMFree, beginProfilingRAM)
       
    79 
       
    80 #define TAG_RAM_PROFILING_END \
       
    81     TInt endProfilingRAM; \
       
    82     TInt err2 = HAL::Get(HALData::EMemoryRAMFree, endProfilingRAM)
       
    83 
       
    84 #define PRINT_TO_CONSOLE_RAM_DIFF \
       
    85     if ((err1 == KErrNone) && (err2 == KErrNone)) \
       
    86         { \
       
    87         TInt diffRAM = (beginProfilingRAM - endProfilingRAM); \
       
    88         if ( diffRAM > 0 ) \
       
    89             { \
       
    90             RDebug::Printf("VPROFILEDAT: %s : RAM used[%u]bytes ", __PRETTY_FUNCTION__, diffRAM); \
       
    91             } \
       
    92         else \
       
    93             { \
       
    94             RDebug::Printf("VPROFILEDAT: %s : RAM freed[%u]bytes ", __PRETTY_FUNCTION__, (-diffRAM)); \
       
    95             } \
       
    96         } \
       
    97     else \
       
    98         { \
       
    99         RDebug::Printf("VPROFILEDAT: %s : Error1[%d] Error2[%d] ", __PRETTY_FUNCTION__, err1, err2); \
       
   100         }
       
   101 
       
   102 #else /* Empty macros */
       
   103 #define TAG_RAM_PROFILING_BEGIN
       
   104 #define TAG_RAM_PROFILING_END
       
   105 #define PRINT_TO_CONSOLE_RAM_DIFF
       
   106 #endif /*PROFILE_RAM_USAGE*/
       
   107 
       
   108 #ifdef PROFILE_HEAP_USAGE
       
   109 #define TAG_DEFAULT_HEAP_PROFILING_BEGIN \
       
   110     TInt beginProfilingHEAPBiggestBlock; \
       
   111     TInt beginProfilingHEAP = User::Available(beginProfilingHEAPBiggestBlock) \
       
   112 
       
   113 #define TAG_DEFAULT_HEAP_PROFILING_END \
       
   114     TInt endProfilingHEAPBiggestBlock; \
       
   115     TInt endProfilingHEAP = User::Available(endProfilingHEAPBiggestBlock) \
       
   116 
       
   117 #define PRINT_TO_CONSOLE_HEAP_DIFF \
       
   118     TInt diffHEAP = beginProfilingHEAP - endProfilingHEAP; \
       
   119     if ( diffHEAP > 0 ) \
       
   120         { \
       
   121         RDebug::Printf("VPROFILEDAT: %s : HEAP used[%u]bytes ", __PRETTY_FUNCTION__, diffHEAP); \
       
   122         } \
       
   123     else \
       
   124         { \
       
   125         RDebug::Printf("VPROFILEDAT: %s : HEAP freed[%u]bytes ", __PRETTY_FUNCTION__, (-diffHEAP)); \
       
   126         }
       
   127 #else /* Empty macros */
       
   128 #define TAG_DEFAULT_HEAP_PROFILING_BEGIN
       
   129 #define TAG_DEFAULT_HEAP_PROFILING_END
       
   130 #define PRINT_TO_CONSOLE_HEAP_DIFF
       
   131 #endif /*PROFILE_HEAP_USAGE*/
       
   132 
       
   133 #endif /* PROFILEUTILMACRO_H */