catch_clock.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Created by Joachim on 16/04/2019.
  3. * Adapted from donated nonius code.
  4. *
  5. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. // Clocks
  9. #ifndef TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED
  10. #define TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED
  11. #include <chrono>
  12. #include <ratio>
  13. namespace Catch {
  14. namespace Benchmark {
  15. template <typename Clock>
  16. using ClockDuration = typename Clock::duration;
  17. template <typename Clock>
  18. using FloatDuration = std::chrono::duration<double, typename Clock::period>;
  19. template <typename Clock>
  20. using TimePoint = typename Clock::time_point;
  21. using default_clock = std::chrono::steady_clock;
  22. template <typename Clock>
  23. struct now {
  24. TimePoint<Clock> operator()() const {
  25. return Clock::now();
  26. }
  27. };
  28. using fp_seconds = std::chrono::duration<double, std::ratio<1>>;
  29. } // namespace Benchmark
  30. } // namespace Catch
  31. #endif // TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED