get_seconds.cpp 856 B

1234567891011121314151617181920212223242526272829
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "get_seconds.h"
  9. // NULL for Linux
  10. #include <cstddef>
  11. #if _WIN32
  12. # include <ctime>
  13. IGL_INLINE double igl::get_seconds()
  14. {
  15. // This does not work on mac os x with glut in the main loop
  16. return double(clock())/CLOCKS_PER_SEC;
  17. }
  18. #else
  19. # include <sys/time.h>
  20. IGL_INLINE double igl::get_seconds()
  21. {
  22. timeval time;
  23. gettimeofday(&time, NULL);
  24. return time.tv_sec + time.tv_usec / 1e6;
  25. // This does not work on mac os x with glut in the main loop
  26. //return double(clock())/CLOCKS_PER_SEC;
  27. }
  28. #endif