get_seconds_hires.cpp 931 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_hires.h"
  9. #if _WIN32
  10. # include <windows.h>
  11. # include <cassert>
  12. IGL_INLINE double igl::get_seconds_hires()
  13. {
  14. LARGE_INTEGER li_freq, li_current;
  15. const bool ret = QueryPerformanceFrequency(&li_freq);
  16. const bool ret2 = QueryPerformanceCounter(&li_current);
  17. assert(ret && ret2);
  18. assert(li_freq.QuadPart > 0);
  19. return double(li_current.QuadPart) / double(li_freq.QuadPart);
  20. }
  21. #else
  22. # include "get_seconds.h"
  23. IGL_INLINE double igl::get_seconds_hires()
  24. {
  25. // Sorry I've no idea how performance counters work on Mac...
  26. return igl::get_seconds();
  27. }
  28. #endif