• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // Measure
10 
11 #ifndef TWOBLUECUBES_CATCH_DETAIL_MEASURE_HPP_INCLUDED
12 #define TWOBLUECUBES_CATCH_DETAIL_MEASURE_HPP_INCLUDED
13 
14 #include "../catch_clock.hpp"
15 #include "catch_complete_invoke.hpp"
16 #include "catch_timing.hpp"
17 
18 #include <utility>
19 
20 namespace Catch {
21     namespace Benchmark {
22         namespace Detail {
23             template <typename Clock, typename Fun, typename... Args>
measure(Fun && fun,Args &&...args)24             TimingOf<Clock, Fun(Args...)> measure(Fun&& fun, Args&&... args) {
25                 auto start = Clock::now();
26                 auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...);
27                 auto end = Clock::now();
28                 auto delta = end - start;
29                 return { delta, std::forward<decltype(r)>(r), 1 };
30             }
31         } // namespace Detail
32     } // namespace Benchmark
33 } // namespace Catch
34 
35 #endif // TWOBLUECUBES_CATCH_DETAIL_MEASURE_HPP_INCLUDED
36