| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
// Copyright Catch2 Authors |
|
3
|
|
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. |
|
4
|
|
|
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at |
|
5
|
|
|
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt) |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0 |
|
8
|
|
|
|
|
|
|
// Adapted from donated nonius code. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#ifndef CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED |
|
11
|
|
|
|
|
|
|
#define CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#include |
|
14
|
|
|
|
|
|
|
#include |
|
15
|
|
|
|
|
|
|
#include |
|
16
|
|
|
|
|
|
|
#include |
|
17
|
|
|
|
|
|
|
#include |
|
18
|
|
|
|
|
|
|
#include |
|
19
|
|
|
|
|
|
|
#include |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#include |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
namespace Catch { |
|
24
|
|
|
|
|
|
|
namespace Benchmark { |
|
25
|
|
|
|
|
|
|
namespace Detail { |
|
26
|
|
|
|
|
|
|
template |
|
27
|
0
|
|
|
|
|
|
TimingOf measure_one(Fun&& fun, int iters, std::false_type) { |
|
28
|
0
|
|
|
|
|
|
return Detail::measure(fun, iters); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
template |
|
31
|
0
|
|
|
|
|
|
TimingOf measure_one(Fun&& fun, int iters, std::true_type) { |
|
32
|
0
|
|
|
|
|
|
Detail::ChronometerModel meter; |
|
33
|
0
|
0
|
|
|
|
|
auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return { meter.elapsed(), CATCH_MOVE(result), iters }; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
template |
|
39
|
|
|
|
|
|
|
using run_for_at_least_argument_t = std::conditional_t::value, Chronometer, int>; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
[[noreturn]] |
|
43
|
|
|
|
|
|
|
void throw_optimized_away_error(); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
template |
|
46
|
|
|
|
|
|
|
TimingOf> |
|
47
|
0
|
|
|
|
|
|
run_for_at_least(ClockDuration how_long, |
|
48
|
|
|
|
|
|
|
const int initial_iterations, |
|
49
|
|
|
|
|
|
|
Fun&& fun) { |
|
50
|
0
|
|
|
|
|
|
auto iters = initial_iterations; |
|
51
|
0
|
0
|
|
|
|
|
while (iters < (1 << 30)) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
auto&& Timing = measure_one(fun, iters, is_callable()); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if (Timing.elapsed >= how_long) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return { Timing.elapsed, CATCH_MOVE(Timing.result), iters }; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
0
|
0
|
|
|
|
|
iters *= 2; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
0
|
|
|
|
|
|
throw_optimized_away_error(); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} // namespace Detail |
|
62
|
|
|
|
|
|
|
} // namespace Benchmark |
|
63
|
|
|
|
|
|
|
} // namespace Catch |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#endif // CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED |