get_seconds.h 461 B

1234567891011121314151617181920212223
  1. #ifndef IGL_GET_SECONDS_H
  2. #define IGL_GET_SECONDS_H
  3. namespace igl
  4. {
  5. // Return the current time in seconds since program start
  6. inline double get_seconds();
  7. }
  8. //Implementation
  9. #include <sys/time.h>
  10. //#include <ctime>
  11. inline double igl::get_seconds()
  12. {
  13. timeval time;
  14. gettimeofday(&time, NULL);
  15. return time.tv_sec + time.tv_usec / 1e6;
  16. // This does not work on mac os x with glut in the main loop
  17. //return double(clock())/CLOCKS_PER_SEC;
  18. }
  19. #endif