Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Debugging/Stopwatch.h

Go to the documentation of this file.
00001 /** 
00002 * @file Stopwatch.h
00003 * Makros and for the Stopwatch
00004 *
00005 * @author <A href=mailto:juengel@informatik.hu-berlin.de>Matthias Jüngel</A>
00006 */
00007 
00008 #ifndef __Stopwatch_h_
00009 #define __Stopwatch_h_
00010 
00011 #include "Tools/Debugging/Debugging.h"
00012 #include "Platform/SystemCall.h"
00013 #include "Platform/GTAssert.h"
00014 
00015 /** 
00016 * @class Stopwatch
00017 * Provides IDs and names for different stopwatch tasks; makros
00018 * are used to provide real stopwatch functionality with that.
00019 */
00020 class Stopwatch
00021 {
00022 public:
00023   enum StopwatchEventID
00024   {
00025     imageProcessor,
00026       sensorDataProcessor,
00027       ballLocator,
00028       teamBallLocator,
00029       selfLocator,
00030       playersLocator,
00031       obstaclesLocator,
00032       behaviorControl,
00033       motionControl,
00034       soundControl,
00035       specialVision,
00036       perceptBehaviorControl,
00037       sensorBehaviorControl,
00038       headControl,
00039       collisionDetector,
00040       robotStateDetector,
00041 
00042       numberOfStopwatchEventIDs
00043   };
00044   
00045   static DebugKeyTable::debugKeyID getDebugKeyID(enum StopwatchEventID stopwatchEventID)
00046   {
00047     switch (stopwatchEventID) 
00048     {
00049    case imageProcessor: return DebugKeyTable::sendImageProcessorTime;
00050    case sensorDataProcessor: return DebugKeyTable::sendSensorDataProcessorTime;
00051    case ballLocator: return DebugKeyTable::sendBallLocatorTime;
00052    case teamBallLocator: return DebugKeyTable::sendTeamBallLocatorTime;
00053    case selfLocator: return DebugKeyTable::sendSelfLocatorTime;
00054    case playersLocator: return DebugKeyTable::sendPlayersLocatorTime;
00055    case obstaclesLocator: return DebugKeyTable::sendObstaclesLocatorTime;
00056    case behaviorControl: return DebugKeyTable::sendBehaviorControlTime;
00057     case motionControl: return DebugKeyTable::sendMotionControlTime;
00058     case soundControl: return DebugKeyTable::sendSoundControlTime;
00059     case specialVision: return DebugKeyTable::sendSpecialVisionTime;
00060     case perceptBehaviorControl: return DebugKeyTable::sendPerceptBehaviorControlTime;
00061     case sensorBehaviorControl: return DebugKeyTable::sendSensorBehaviorControlTime;
00062     case headControl: return DebugKeyTable::sendHeadControlTime;
00063     case collisionDetector: return DebugKeyTable::sendCollisionDetectorTime;
00064     case robotStateDetector: return DebugKeyTable::sendRobotStateDetectorTime;
00065     default: 
00066       {
00067         ASSERT(false);
00068         return (DebugKeyTable::debugKeyID)0;
00069       }
00070     }
00071   }
00072   
00073   static const char* getStopwatchEventIDName(enum StopwatchEventID stopwatchEventID)
00074   {
00075     switch (stopwatchEventID) 
00076     {
00077    case imageProcessor: return "imageProcessor";
00078    case sensorDataProcessor: return "sensorDataProcessor";
00079    case ballLocator: return "ballLocator";
00080    case teamBallLocator: return "teamBallLocator";
00081    case selfLocator: return "selfLocator";
00082    case playersLocator: return "playersLocator";
00083    case obstaclesLocator: return "obstaclesLocator";
00084    case behaviorControl: return "behaviorControl";
00085    case perceptBehaviorControl: return "perceptBehaviorControl";
00086    case sensorBehaviorControl: return "sensorBehaviorControl";
00087     case motionControl: return "motionControl";
00088     case soundControl: return "soundControl";
00089     case specialVision: return "specialVision";
00090     case headControl: return "headControl";
00091     case collisionDetector: return "collisionDetector";
00092     case robotStateDetector: return "robotStateDetector";
00093     default: return "check available stopwatchEventIDs";
00094     }
00095   }
00096 };
00097 
00098 #ifdef NDEBUG
00099 
00100 #define STOP_TIME_ON_REQUEST(eventID, expression) expression
00101 #define STOP_TIME(expression) expression/**/
00102 
00103 #else //NDEBUG
00104 
00105 /**
00106 * Stops the execution time of "expression"  if a DebugKey is set for the eventID.
00107 * The start and stop times are sent as a idStopwatch message to RobotControl
00108 */
00109 
00110 #define STOP_TIME_ON_REQUEST(eventID, expression) \
00111   if (getDebugKeyTable().isActive(Stopwatch::getDebugKeyID(Stopwatch::eventID))) \
00112 {\
00113   unsigned long eventID##StartTime; \
00114   static unsigned long evendID##Counter = 0; \
00115   eventID##StartTime = SystemCall::getCurrentSystemTime();\
00116   expression \
00117   OUTPUT(idStopwatch, bin, (char) Stopwatch::eventID << eventID##StartTime << SystemCall::getCurrentSystemTime() << evendID##Counter++)\
00118 }\
00119   else {expression}\
00120 
00121 
00122 /** 
00123 * Starts a StopWatch without an id.
00124 */
00125 #define STOP_TIME(expression) \
00126 {\
00127   unsigned long stopwatchStartTime = SystemCall::getCurrentSystemTime();\
00128   expression\
00129   OUTPUT(idText, text, "Stopwatch: " << SystemCall::getTimeSince(stopwatchStartTime) << "ms")\
00130 }\
00131 
00132 #endif //NDEBUG
00133 
00134 #endif //Stopwatch_h
00135 
00136 /*
00137  * Change log :
00138  * 
00139  * $Log: Stopwatch.h,v $
00140  * Revision 1.1.1.1  2004/05/22 17:36:06  cvsadm
00141  * created new repository GT2004_WM
00142  *
00143  * Revision 1.1  2003/10/07 10:13:22  cvsadm
00144  * Created GT2004 (M.J.)
00145  *
00146  * Revision 1.1  2003/09/26 11:40:40  juengel
00147  * - sorted tools
00148  * - clean-up in DataTypes
00149  *
00150  * Revision 1.3  2003/09/01 15:09:37  juengel
00151  * Removed playersPerceptor
00152  *
00153  * Revision 1.2  2003/09/01 10:23:14  juengel
00154  * DebugDrawings clean-up 2
00155  * DebugImages clean-up
00156  * MessageIDs clean-up
00157  * Stopwatch clean-up
00158  *
00159  * Revision 1.1.1.1  2003/07/02 09:40:28  cvsadm
00160  * created new repository for the competitions in Padova from the 
00161  * tamara CVS (Tuesday 2:00 pm)
00162  *
00163  * removed unused solutions
00164  *
00165  * Revision 1.15  2003/06/24 08:10:53  dueffert
00166  * stopping times works in WIN32 again, no special (buggy) solution any more
00167  *
00168  * Revision 1.14  2003/06/22 12:55:24  roefer
00169  * Stopwatch RT compatible (2nd try)
00170  *
00171  * Revision 1.13  2003/06/22 09:55:12  roefer
00172  * Stopwatch now RT compatible
00173  *
00174  * Revision 1.12  2003/06/21 12:49:25  juengel
00175  * Added robotStateDetector.
00176  *
00177  * Revision 1.11  2003/05/26 20:35:44  goehring
00178  * collisionDetectorTime added
00179  *
00180  * Revision 1.10  2003/05/08 13:20:22  loetzsch
00181  * added the execution of the team ball locator to the Cognition process
00182  *
00183  * Revision 1.9  2003/04/16 07:00:17  roefer
00184  * Bremen GO checkin
00185  *
00186  * Revision 1.9  2003/04/08 18:24:42  roefer
00187  * HeadControl time measurement added
00188  *
00189  * Revision 1.8  2003/03/24 09:56:25  schumann
00190  * added profiling for strategical database
00191  *
00192  * Revision 1.7  2003/03/12 13:46:04  dasmuli
00193  * PlayersPerceptor added to cognition, modules.cfg, DebugKey-table etc.
00194  *
00195  * Revision 1.6  2003/03/10 14:00:52  juengel
00196  * Added ObstaclesLocator
00197  *
00198  * Revision 1.5  2002/11/27 13:47:21  dueffert
00199  * doxygen docu added
00200  *
00201  * Revision 1.4  2002/11/26 19:22:18  juengel
00202  * added stopwatchID for SensorBehaviorControl
00203  *
00204  * Revision 1.3  2002/10/02 15:50:54  loetzsch
00205  * added the debug key sendPerceptBehaviorControlTime
00206  *
00207  * Revision 1.2  2002/10/01 11:14:34  loetzsch
00208  * Redesigned DebugKey and DebugKeyTable
00209  *
00210  * Revision 1.1  2002/09/10 15:53:58  cvsadm
00211  * Created new project GT2003 (M.L.)
00212  * - Cleaned up the /Src/DataTypes directory
00213  * - Removed challenge related source code
00214  * - Removed processing of incoming audio data
00215  * - Renamed AcousticMessage to SoundRequest
00216  *
00217  * Revision 1.8  2002/09/07 13:36:55  loetzsch
00218  * unified the vision modules into one module "ImageProcessor"
00219  * - FloodFillRLEImageProcessor, BallPerceptor, LandmarksPerceptor
00220  *   and PlayersPerceptor were are combined to the new solution
00221  *   "BlobImageProcessor"
00222  * - The GridImageProcessor and the SubPixelGradientCalculator became
00223  *   a solution of "ImageProcessor"
00224  *
00225  * Revision 1.7  2002/07/23 13:48:41  loetzsch
00226  * - new streaming classes
00227  * - removed many #include statements
00228  * - exchanged StaticQueue by MessageQueue
00229  * - new debug message handling
00230  * - general clean up
00231  *
00232  * Revision 1.6  2002/06/22 03:05:20  dueffert
00233  * bug fixed: never return numOfDebugKeys
00234  *
00235  * Revision 1.5  2002/06/12 11:34:29  roefer
00236  * SimpleLinesPerceptor removed, PerceptBehaviorControl added
00237  *
00238  * Revision 1.4  2002/05/26 15:33:43  loetzsch
00239  * removed the looped execution of modules in _WIN32
00240  *
00241  * Revision 1.3  2002/05/14 20:58:05  hebbel
00242  * added id for SoundInProcessor
00243  *
00244  * Revision 1.2  2002/05/10 17:31:35  juengel
00245  * Added SpecialVision and SpecialPercept.
00246  *
00247  * Revision 1.16  2002/05/03 17:14:35  giese
00248  * StopTimeOnRequest for SoundOutControl added
00249  *
00250  * Revision 1.15  2002/03/16 13:44:49  juengel
00251  * GridImageProcessor created.
00252  *
00253  * Revision 1.14  2002/02/28 10:39:12  juengel
00254  * change log added.
00255  *
00256  *
00257  */
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 
00269 

Generated on Thu Sep 23 19:57:37 2004 for GT2004 by doxygen 1.3.6