Vuo  2.3.2
VuoTimeUtilities.cc
Go to the documentation of this file.
1 
10 #include <sys/time.h>
11 #include "VuoTimeUtilities.hh"
12 
17 {
18  struct timeval t = getCurrentTime();
19  return t.tv_sec + t.tv_usec / 1000000.;
20 }
21 
25 struct timeval VuoTimeUtilities::getCurrentTime(void)
26 {
27  struct timeval now;
28  gettimeofday(&now, NULL);
29  return now;
30 }
31 
35 struct timeval VuoTimeUtilities::getElapsedTime(const struct timeval &start, const struct timeval &end)
36 {
37  long int diff = (end.tv_usec + 1000000 * end.tv_sec) - (start.tv_usec + 1000000 * start.tv_sec);
38  struct timeval result;
39  result.tv_sec = diff / 1000000;
40  result.tv_usec = diff % 1000000;
41  return result;
42 }
43 
47 void VuoTimeUtilities::printTime(const struct timeval &time)
48 {
49  printf("%ld.%06d\n", time.tv_sec, time.tv_usec);
50 }