00001 /* --------------------------------------------------------------------------- 00002 Phission : 00003 Realtime Vision Processing System 00004 00005 Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu) 00006 University of Massachusetts at Lowell, 00007 Laboratory for Artificial Intelligence and Robotics 00008 00009 This file is part of Phission. 00010 00011 Phission is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU Lesser General Public License as published by 00013 the Free Software Foundation; either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 Phission is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public License 00022 along with Phission; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 ---------------------------------------------------------------------------*/ 00026 #ifndef _PHTIMEINTERVAL_H 00027 #define _PHTIMEINTERVAL_H 00028 00029 #include <phStandard.h> 00030 #include <phStdint.h> 00031 #include <phList.h> 00032 #include <phTimeStamp.h> 00033 00034 /* ---------------------------------------------------------------------- */ 00038 /* ---------------------------------------------------------------------- */ 00044 PHAPI(class) phTimeInterval : public phListNode 00045 { 00046 private: 00047 phTimeStamp m_start; 00048 phTimeStamp m_stop; 00049 00050 phTimeStamp m_elapsed; 00051 phTimeStamp m_last_elapsed; 00052 00053 char *m_label; 00054 uint32_t m_labelLength; 00055 00056 uint32_t m_stopped; 00057 00058 public: 00059 phTimeInterval( char *label = NULL ); 00060 ~phTimeInterval(); 00061 00062 void start(); 00063 void stop (); 00064 00065 void clear(); 00066 00067 int setLabel( char *label ); 00068 00069 phTimeStamp elapsed(); 00070 phTimeStamp lastElapsed(); 00071 00072 void report( char *label = NULL, 00073 FILE *file_desc= NULL ); 00074 00075 /* Assignment operator */ 00076 phTimeInterval &operator =( const phTimeInterval &right ); 00077 00078 phTimeInterval *getNextInterval(); 00079 phTimeInterval *getPreviousInterval(); 00080 }; 00081 00082 /* ---------------------------------------------------------------------- */ 00083 /* from 'man gettimeofday' */ 00084 /* Available macros, usually found in time.h 00085 * 00086 * timerisset(tvp) 00087 * timerclear(tvp) 00088 * timercmp(a, b, CMP) doesn't work for >= <= 00089 * timeradd(a, b, result) 00090 * timersub(a, b, result) 00091 */ 00092 /* ------------------------------------------------------------------------- 00093 # ifdef __USE_POSIX199309 00094 // Pause execution for a number of nanoseconds. 00095 extern int nanosleep (__const struct timespec *__requested_time, 00096 struct timespec *__remaining) __THROW; 00097 00098 00099 // Get resolution of clock CLOCK_ID. 00100 extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW; 00101 00102 // Get current value of clock CLOCK_ID and store it in TP. 00103 extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW; 00104 00105 // Set clock CLOCK_ID to value TP. 00106 extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp) 00107 __THROW; 00108 00109 # ifdef __USE_XOPEN2K 00110 // High-resolution sleep with the specified clock. 00111 extern int clock_nanosleep (clockid_t __clock_id, int __flags, 00112 __const struct timespec *__req, 00113 struct timespec *__rem) __THROW; 00114 00115 // Return clock ID for CPU-time clock. 00116 extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW; 00117 # endif 00118 * ------------------------------------------------------------------------ */ 00119 /* ----------------------------------------------------------------------- 00120 * char *asctime(const struct tm *tm); 00121 char *asctime_r(const struct tm *tm, char *buf); 00122 00123 char *ctime(const time_t *timep); 00124 char *ctime_r(const time_t *timep, char *buf); 00125 00126 struct tm *gmtime(const time_t *timep); 00127 struct tm *gmtime_r(const time_t *timep, struct tm *result); 00128 00129 struct tm *localtime(const time_t *timep); 00130 struct tm *localtime_r(const time_t *timep, struct tm *result); 00131 00132 time_t mktime(struct tm *tm); 00133 00134 struct tm { 00135 int tm_sec; // seconds 00136 int tm_min; // minutes 00137 int tm_hour; // hours 00138 int tm_mday; // day of the month 00139 int tm_mon; // month 00140 int tm_year; // year 00141 int tm_wday; // day of the week 00142 int tm_yday; // day in the year 00143 int tm_isdst; // daylight saving time 00144 }; 00145 */ 00146 00147 #endif /* _PHTIMEINTERVAL_H */
Copyright (C) 2002 - 2007 |
Philip D.S. Thoren ( pthoren@users.sourceforge.net ) University Of Massachusetts at Lowell Robotics Lab |