cgma
CpuTimer.hpp
Go to the documentation of this file.
00001 //- Class: CpuTimer
00002 
00003 #if !defined(CPU_TIMER)
00004 #define CPU_TIMER
00005 #include <sys/types.h>
00006 #ifndef _WIN32
00007 #include <sys/time.h>
00008 #else
00009 #include <time.h>
00010 #endif
00011 #include "CGMUtilConfigure.h"
00012 
00013 
00014 class CUBIT_UTIL_EXPORT CpuTimer {
00015 public:
00016   CpuTimer();           //- initialise to current system time
00017   double cpu_secs();                //- return CPU time in seconds since last
00018                                 //- call to cpu_secs();
00019   double clock_secs();          //- return wall clock time in seconds since last
00020                                 //- call to clock_secs();
00021   double elapsed(bool wall_time = false);    //- return CPU time in seconds since 'birth' if 
00022                                              //- wall_time is false, else returns the wall clock time.
00023   
00024 private:
00025   time_t cpu;           //- cpu time in 1/HZ units since last call
00026                                 //- to cpu_secs()
00027   time_t cpuInitial;             //- cpu time in 1/HZ units since construction.
00028 
00029 
00030     // Added by Cat for NT port
00031   #ifdef _WIN32
00032   void  nt_times(struct tms *);
00033   clock_t wallTimeInitial;
00034   clock_t wallTime;
00035   #else
00036   timeval wallTimeInitial;     //- Time at construction.
00037   timeval wallTime;            //- Time since last call.
00038   #endif
00039 };
00040 
00041 #endif
00042 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines