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 9 // Clocks 10 11 #ifndef TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED 12 #define TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED 13 14 #include <chrono> 15 #include <ratio> 16 17 namespace Catch { 18 namespace Benchmark { 19 template <typename Clock> 20 using ClockDuration = typename Clock::duration; 21 template <typename Clock> 22 using FloatDuration = std::chrono::duration<double, typename Clock::period>; 23 24 template <typename Clock> 25 using TimePoint = typename Clock::time_point; 26 27 using default_clock = std::chrono::steady_clock; 28 29 template <typename Clock> 30 struct now { operator ()Catch::Benchmark::now31 TimePoint<Clock> operator()() const { 32 return Clock::now(); 33 } 34 }; 35 36 using fp_seconds = std::chrono::duration<double, std::ratio<1>>; 37 } // namespace Benchmark 38 } // namespace Catch 39 40 #endif // TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED 41