$search
00001 00008 /***************************************************************************** 00009 ** Platform Check 00010 *****************************************************************************/ 00011 00012 #include <ecl/config.hpp> 00013 00014 #if defined(ECL_IS_POSIX) 00015 // monotonic clock, cpu clock -> clock_gettime; clock_selection -> clock_nanosleep 00016 #if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK) >= 0L && defined(_POSIX_CLOCK_SELECTION) && (_POSIX_CLOCK_SELECTION) >= 0L 00017 00018 00019 /***************************************************************************** 00020 ** Includes 00021 *****************************************************************************/ 00022 00023 #include "../../include/ecl/time/cpuwatch_rt.hpp" 00024 #include <ecl/time_lite/cpu_time.hpp> 00025 00026 /***************************************************************************** 00027 ** Namespaces 00028 *****************************************************************************/ 00029 00030 namespace ecl { 00031 00032 /***************************************************************************** 00033 ** Implementation [CpuWatch] 00034 *****************************************************************************/ 00035 00036 CpuWatch::CpuWatch() { 00037 cpu_time(tmp); 00038 start_time.stamp(tmp.tv_sec, tmp.tv_nsec); 00039 split_time = start_time; 00040 }; 00041 00042 /***************************************************************************** 00043 ** Implementation 00044 *****************************************************************************/ 00045 00046 void CpuWatch::restart() 00047 { 00048 cpu_time(tmp); 00049 start_time.stamp(tmp.tv_sec, tmp.tv_nsec); 00050 split_time = start_time; 00051 } 00052 00053 TimeStamp CpuWatch::elapsed() 00054 { 00055 cpu_time(tmp); 00056 TimeStamp current_time(tmp.tv_sec, tmp.tv_nsec); 00057 return ( current_time - start_time ); 00058 } 00059 00060 TimeStamp CpuWatch::split() 00061 { 00062 TimeStamp last_time = split_time; 00063 cpu_time(tmp); 00064 split_time.stamp(tmp.tv_sec,tmp.tv_nsec); 00065 return (split_time - last_time); 00066 } 00067 00068 }; // namespace ecl 00069 00070 #endif /* MANY POSIX TIME REQ'MENTS */ 00071 #endif /* ECL_IS_POSIX */ 00072