Panda3D

pStatTimer.h

00001 // Filename: pStatTimer.h
00002 // Created by:  drose (11Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PSTATTIMER_H
00016 #define PSTATTIMER_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "pStatCollector.h"
00021 
00022 class Thread;
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : PStatTimer
00026 // Description : A lightweight class that can be used to automatically
00027 //               start and stop a PStatCollector around a section of
00028 //               code.  It's intended to be used in the following way:
00029 //               create a local PStatTimer variable to start the
00030 //               Collector, and when the PStatTimer variable goes out
00031 //               of scope (for instance, at the end of the function),
00032 //               it will automatically stop the Collector.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDA_PSTATCLIENT PStatTimer {
00035 public:
00036 #ifdef DO_PSTATS
00037   INLINE PStatTimer(PStatCollector &collector);
00038   INLINE PStatTimer(PStatCollector &collector, Thread *current_thread);
00039   INLINE ~PStatTimer();
00040 
00041 private:
00042   PStatCollector &_collector;
00043   PStatThread _thread;
00044 #else // DO_PSTATS
00045 
00046   INLINE PStatTimer(PStatCollector &) { } 
00047   INLINE PStatTimer(PStatCollector &, Thread *) { }
00048   INLINE ~PStatTimer() { }
00049 
00050 #endif  // DO_PSTATS
00051 };
00052 
00053 #include "pStatTimer.I"
00054 
00055 #endif
00056 
 All Classes Functions Variables Enumerations