loggers/loggerqt/inc/glxperformancemacro.h
changeset 23 74c9f037fd5d
equal deleted inserted replaced
5:f7f0874bfe7d 23:74c9f037fd5d
       
     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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef GLXPERFORMANCEMACRO_H
       
    19 #define GLXPERFORMANCEMACRO_H
       
    20 
       
    21 #include<glxperformancelog.h>
       
    22 
       
    23 #ifdef GLXPERFORMANCE_LOG
       
    24 
       
    25 /*
       
    26  * create the object of performance log.
       
    27  */
       
    28     #define CREATE_PERLOG(X) 	GlxPerformanceLog _##X;	
       
    29 
       
    30 /*
       
    31  * measure the time required for execute the group of statements
       
    32  * example
       
    33  *     START_PERLOG( t ) //t object should be created using CREATE_PERLOG (t)
       
    34  *          group of statements
       
    35  *     STOP_PERLOG ( t )
       
    36  */
       
    37     #define START_PERLOG(X)			_##X.start();
       
    38     #define STOP_PERLOG(X)			_##X.stop();
       
    39 
       
    40 /*
       
    41  * reset the performance log informanation of object X.
       
    42  */
       
    43     #define END_PERLOG(X)			_##X.end();
       
    44 
       
    45 /*
       
    46  * update the performance log information into flash.
       
    47  */
       
    48 	#define WRITE_PERLOG(X,Y)		_##X.appendPerformanceLog(#Y);
       
    49 
       
    50 /*
       
    51  * update the log info message of object X
       
    52  */
       
    53 	#define UPDATE_PERLOGINFO(X,Y)	_##X.setInfoMsg(#Y);
       
    54 
       
    55 /*
       
    56  * single macro to calculate the performance of group of statement, no need to create the object
       
    57  * example
       
    58  * PERFORMANCE( t, execution time ) {
       
    59  * statements
       
    60  * }
       
    61  */
       
    62     #define PERFORMANCE(X,Y) \
       
    63     GlxPerformanceLog _##X ;\
       
    64     _##X.start() ;\
       
    65     for ( int _i##X = 1 ; _i##X > 0 ; _##X.done(#Y), --_i##X )
       
    66 
       
    67 /*
       
    68  * single macro to calculate the performance of group of statement, no need to create the object. 
       
    69  * It will take a parameter as string
       
    70  * example
       
    71  * PERFORMANCE_ADV( t, "execution time" ) {
       
    72  * statements
       
    73  * }
       
    74  */
       
    75     #define PERFORMANCE_ADV(X,Y) \
       
    76     GlxPerformanceLog _##X ;\
       
    77     _##X.start() ;\
       
    78     for ( int _i##X = 1 ; _i##X > 0 ; _##X.done(Y), --_i##X )
       
    79 
       
    80 
       
    81 /*
       
    82  * single macro to calculate the avg performanc of group of statement, it is mandatory to create the object before using it
       
    83  * example
       
    84  * PERFORMANCE( t ) {
       
    85  * group of statements
       
    86  * }
       
    87  */
       
    88     #define AVG_PERFORMANCE(X) \
       
    89     _##X.start();\
       
    90     for ( int _i##X = 1; _i##X > 0; _##X.stopMonitor(), --_i##X )
       
    91 
       
    92 /*
       
    93  * single macro to create the object, set the info and start the performance measurments
       
    94  * example
       
    95  * START_PERFORMANCE( t,  ) 
       
    96  * group of statements
       
    97  * STOP_PERLOG ( t)
       
    98  */
       
    99     #define START_PERFORMANCE(X,Y) \
       
   100     GlxPerformanceLog _##X ;\
       
   101     _##X.setInfoMsg(#Y);\
       
   102     _##X.start() ;
       
   103 
       
   104 /*
       
   105  * write the current Time Stamp on the log file
       
   106  */
       
   107     #define WRITE_TIMESTAMP(X) {\
       
   108     GlxPerformanceLog tmp ;\
       
   109     tmp.appendTimeStamp(X);\
       
   110     }
       
   111 
       
   112 #else
       
   113 	#define CREATE_PERLOG(X) 
       
   114 	#define START_PERLOG(X)
       
   115 	#define STOP_PERLOG(X)
       
   116 	#define END_PERLOG(X)
       
   117 	#define WRITE_PERLOG(X,Y)
       
   118 	#define UPDATE_PERLOGINFO(X,Y)
       
   119     #define PERFORMANCE(X,Y)
       
   120     #define PERFORMANCE_ADV(X,Y)
       
   121     #define AVG_PERFORMANCE(X)
       
   122     #define START_PERFORMANCE(X,Y)
       
   123     #define WRITE_TIMESTAMP(X)
       
   124 #endif
       
   125 
       
   126 
       
   127 
       
   128 #endif /* GLXPERFORMANCEMACRO_H_ */