get_seconds.cpp 510 B

12345678910111213141516171819202122
  1. #include "get_seconds.h"
  2. // NULL for Linux
  3. #include <cstddef>
  4. #if _WIN32
  5. # include <ctime>
  6. IGL_INLINE double igl::get_seconds()
  7. {
  8. // This does not work on mac os x with glut in the main loop
  9. return double(clock())/CLOCKS_PER_SEC;
  10. }
  11. #else
  12. # include <sys/time.h>
  13. IGL_INLINE double igl::get_seconds()
  14. {
  15. timeval time;
  16. gettimeofday(&time, NULL);
  17. return time.tv_sec + time.tv_usec / 1e6;
  18. // This does not work on mac os x with glut in the main loop
  19. //return double(clock())/CLOCKS_PER_SEC;
  20. }
  21. #endif