18 #include <ecl/time_lite/config.hpp> 19 #include "../../include/ecl/time_lite/date.hpp" 20 #include "../../include/ecl/time_lite/functions.hpp" 21 #include "../../include/ecl/time_lite/cpu_time.hpp" 30 #if defined(ECL_HAS_POSIX_TIMERS) || defined(ECL_HAS_RT_TIMERS) || defined(ECL_HAS_WIN_TIMERS) || defined(ECL_HAS_MACH_TIMERS) 32 ecl::TimeStructure duration, timestamp;
34 std::cout << std::endl;
35 std::cout <<
"***********************************************************" << std::endl;
36 std::cout <<
" Sleep" << std::endl;
37 std::cout <<
"***********************************************************" << std::endl;
38 std::cout << std::endl;
41 std::cout <<
"Sleep: Duration 1.3s" << std::endl;
43 duration.tv_nsec = 300000000;
44 error = ecl::sleep(duration);
50 std::cout << std::endl;
51 std::cout <<
"***********************************************************" << std::endl;
52 std::cout <<
" Epoch Time" << std::endl;
53 std::cout <<
"***********************************************************" << std::endl;
54 std::cout << std::endl;
56 error = ecl::epoch_time(timestamp);
60 std::cout <<
"Epoch Time:" << std::endl;
61 std::cout <<
" sec : " << timestamp.tv_sec << std::endl;
62 std::cout <<
" nsec: " << timestamp.tv_nsec << std::endl;
64 std::cout << std::endl;
65 std::cout <<
"***********************************************************" << std::endl;
66 std::cout <<
" Sleep Until" << std::endl;
67 std::cout <<
"***********************************************************" << std::endl;
68 std::cout << std::endl;
70 timestamp.tv_sec += 2;
71 std::cout <<
"Sleeping until current_time + 2 seconds." << std::endl;
72 error = ecl::sleep_until(timestamp);
77 #ifdef ECL_HAS_CPUTIME 78 std::cout << std::endl;
79 std::cout <<
"***********************************************************" << std::endl;
80 std::cout <<
" Cpu Time" << std::endl;
81 std::cout <<
"***********************************************************" << std::endl;
82 std::cout << std::endl;
84 error = ecl::cpu_time(timestamp);
88 std::cout <<
"Cpu Time:" << std::endl;
89 std::cout <<
" sec : " << timestamp.tv_sec << std::endl;
90 std::cout <<
" nsec: " << timestamp.tv_nsec << std::endl;
93 std::cout << std::endl;
94 std::cout <<
"***********************************************************" << std::endl;
95 std::cout <<
" Date String" << std::endl;
96 std::cout <<
"***********************************************************" << std::endl;
97 std::cout << std::endl;
99 std::cout <<
"Date String: " << ecl::get_date_string() << std::endl;
101 std::cout << std::endl;
102 std::cout <<
"***********************************************************" << std::endl;
103 std::cout <<
" Passed" << std::endl;
104 std::cout <<
"***********************************************************" << std::endl;
105 std::cout << std::endl;
109 std::cout << std::endl;
110 std::cout <<
"***********************************************************" << std::endl;
111 std::cout <<
" This platform does not support timers. " << std::endl;
112 std::cout <<
"***********************************************************" << std::endl;
113 std::cout << std::endl;
virtual ErrorFlag flag() const
Extends the generic ecl error handler with some time specific error strings.