get_seconds_hires.h 738 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef IGL_GET_SECONDS_HIRES_H
  2. #define IGL_GET_SECONDS_HIRES_H
  3. namespace igl
  4. {
  5. // Return the current time in seconds using performance counters
  6. inline double get_seconds_hires();
  7. }
  8. // Implementation
  9. #if _WIN32
  10. # include <windows.h>
  11. inline double igl::get_seconds_hires()
  12. {
  13. LARGE_INTEGER li_freq, li_current;
  14. const bool ret = QueryPerformanceFrequency(&li_freq);
  15. const bool ret2 = QueryPerformanceCounter(&li_current);
  16. assert(ret && ret2);
  17. assert(li_freq.QuadPart > 0);
  18. return double(li_current.QuadPart) / double(li_freq.QuadPart);
  19. }
  20. #else
  21. # include "get_seconds.h"
  22. inline double igl::get_seconds_hires()
  23. {
  24. // Sorry I've no idea how performance counters work on Mac...
  25. return igl::get_seconds();
  26. }
  27. #endif
  28. #endif