annotate core/Clock.cpp @ 135:e77e2e712fbc ClockSync

To work with the ClockSync plugin
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 12 Sep 2015 20:05:55 +0100
parents
children 772dbb57442b
rev   line source
giuliomoro@135 1 #include "Clock.h"
giuliomoro@135 2
giuliomoro@135 3 namespace Clock
giuliomoro@135 4 {
giuliomoro@135 5 myClock_t getTimeUs(){
giuliomoro@135 6 struct timeval tv;
giuliomoro@135 7 struct timezone tz;
giuliomoro@135 8 int ret=gettimeofday(&tv, &tz);
giuliomoro@135 9 if(ret == -1){
giuliomoro@135 10 printf("Error while getting time of the day\n");
giuliomoro@135 11 return -1;
giuliomoro@135 12 }
giuliomoro@135 13 myClock_t time=tv.tv_usec + tv.tv_sec*1e6;
giuliomoro@135 14 // printf("Time is: %.6f\n", time/1000000.0);
giuliomoro@135 15 // printf("Time is: %lld\n", time);
giuliomoro@135 16 return time;
giuliomoro@135 17 }
giuliomoro@135 18 };