get_seconds.cpp 971 B

12345678910111213141516171819202122232425262728293031
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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. #if _WIN32
  10. // Alec: Why is this more "hires" than chrono?
  11. # include <windows.h>
  12. # include <cassert>
  13. IGL_INLINE double igl::get_seconds()
  14. {
  15. LARGE_INTEGER li_freq, li_current;
  16. const bool ret = QueryPerformanceFrequency(&li_freq);
  17. const bool ret2 = QueryPerformanceCounter(&li_current);
  18. assert(ret && ret2);
  19. assert(li_freq.QuadPart > 0);
  20. return double(li_current.QuadPart) / double(li_freq.QuadPart);
  21. }
  22. #else
  23. #include <chrono>
  24. IGL_INLINE double igl::get_seconds()
  25. {
  26. return
  27. std::chrono::duration<double>(
  28. std::chrono::system_clock::now().time_since_epoch()).count();
  29. }
  30. #endif