|
General IRI utilities
|
This test checks all functions in CTime class.This example tests time creation and set, time operations (-,+,==,/), get time in different formats and throws an exception.
This example output will be something similar to this:
TIME MANAGER EXAMPLE Example: create times (t0,t1,t2) t0: 1314886453.799155 Example: sleep 300 ms Example: set t1 (0.300 rel) t1: 1314886454.099320 t1o: 0.300164 Example: set t3 delayed 200 ms (0.200 abs) t3: 0.200000 Example: sleep 1705 ms Example: set t2 (2.005 rel) t2: 1314886455.804489 t2o: 2.005333 Example: t2 - t1 (1.705) td: 1.705169 tdo: 1.705169 Example: + addition (t1+t2) ts: 2629772909.903809 tso: 2.305498 ulongmax: 4294967295 Example: + Exception (overvalue) [Exception caught] - CTime CTime::operator+(CTime&) at /home/mmorta/codi/drivers/iriutils/trunk/src/time/ctime.cpp:195 Error: [CTime class] - Result higher than ulong max Example: average (t1,t2) ta: 1314886454.951905 tao: 1.152749 Example: comparative (t1==t2, t3==t2) ?: false true Example: comparative (t1<t2, t1<=t2, t3>t2, t3>=t2) t1: 1314886454.099320 t2: 1314886455.804489 t3: 1314886455.804489 ?: <: true <=: true ?: >: false >=: true Example: getting time (t1/t0) seconds and nanoseconds: 1314886454 99320101 0 300164204 double Seconds: 1.31489e+09 0 double milliseconds: 6.26462e+08 300 Format ctf_secnano: 1314886454 099320101 0 300164204 Format ctf_datetime: 2011-09-01,16:14:14 1970-01-01,01:00:00 Format ctf_ms: 1314886454.099 0.300 Format ctf_us: 1314886454.099320 0.300164 Timespec 1314886454 99320101 Time_t 1314886454 some formats using time_t 2011-09-01,16:14:14 04:14PM Thu Sep 1 16:14:14 2011 Example: Using Reference Time Set Reference and wait 1 second Time ref: 1314886455.805064 t1: 1.000107 t2: 1314886455.804489 Set useRef(true) for t2 and set its time t2: 1.000163 Is ref used?: true Example: END
In this example namespace std is used because cout and endl are used a lot.
The example code is the following:
1.8.6