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_EXECUTION_PLAN_HPP_INCLUDED |
11
|
|
|
|
|
|
|
#define CATCH_EXECUTION_PLAN_HPP_INCLUDED |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#include |
14
|
|
|
|
|
|
|
#include |
15
|
|
|
|
|
|
|
#include |
16
|
|
|
|
|
|
|
#include |
17
|
|
|
|
|
|
|
#include |
18
|
|
|
|
|
|
|
#include |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#include |
21
|
|
|
|
|
|
|
#include |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
namespace Catch { |
24
|
|
|
|
|
|
|
namespace Benchmark { |
25
|
|
|
|
|
|
|
template |
26
|
0
|
|
|
|
|
|
struct ExecutionPlan { |
27
|
|
|
|
|
|
|
int iterations_per_sample; |
28
|
|
|
|
|
|
|
Duration estimated_duration; |
29
|
|
|
|
|
|
|
Detail::BenchmarkFunction benchmark; |
30
|
|
|
|
|
|
|
Duration warmup_time; |
31
|
|
|
|
|
|
|
int warmup_iterations; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
template |
34
|
|
|
|
|
|
|
operator ExecutionPlan() const { |
35
|
|
|
|
|
|
|
return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations }; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
template |
39
|
0
|
|
|
|
|
|
std::vector> run(const IConfig &cfg, Environment> env) const { |
40
|
|
|
|
|
|
|
// warmup a bit |
41
|
0
|
0
|
|
|
|
|
Detail::run_for_at_least(std::chrono::duration_cast>(warmup_time), warmup_iterations, Detail::repeat(now{})); |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
std::vector> times; |
44
|
0
|
0
|
|
|
|
|
times.reserve(cfg.benchmarkSamples()); |
|
|
0
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
Detail::ChronometerModel model; |
47
|
0
|
0
|
|
|
|
|
this->benchmark(Chronometer(model, iterations_per_sample)); |
48
|
0
|
|
|
|
|
|
auto sample_time = model.elapsed() - env.clock_cost.mean; |
49
|
0
|
0
|
|
|
|
|
if (sample_time < FloatDuration::zero()) sample_time = FloatDuration::zero(); |
50
|
0
|
|
|
|
|
|
return sample_time / iterations_per_sample; |
51
|
|
|
|
|
|
|
}); |
52
|
0
|
|
|
|
|
|
return times; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
} // namespace Benchmark |
56
|
|
|
|
|
|
|
} // namespace Catch |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#endif // CATCH_EXECUTION_PLAN_HPP_INCLUDED |