| 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_ANALYSE_HPP_INCLUDED |
|
11
|
|
|
|
|
|
|
#define CATCH_ANALYSE_HPP_INCLUDED |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#include |
|
14
|
|
|
|
|
|
|
#include |
|
15
|
|
|
|
|
|
|
#include |
|
16
|
|
|
|
|
|
|
#include |
|
17
|
|
|
|
|
|
|
#include |
|
18
|
|
|
|
|
|
|
#include |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#include |
|
21
|
|
|
|
|
|
|
#include |
|
22
|
|
|
|
|
|
|
#include |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
namespace Catch { |
|
25
|
|
|
|
|
|
|
namespace Benchmark { |
|
26
|
|
|
|
|
|
|
namespace Detail { |
|
27
|
|
|
|
|
|
|
template |
|
28
|
0
|
|
|
|
|
|
SampleAnalysis analyse(const IConfig &cfg, Environment, Iterator first, Iterator last) { |
|
29
|
0
|
0
|
|
|
|
|
if (!cfg.benchmarkNoAnalysis()) { |
|
30
|
0
|
|
|
|
|
|
std::vector samples; |
|
31
|
0
|
0
|
|
|
|
|
samples.reserve(last - first); |
|
32
|
0
|
0
|
|
|
|
|
std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); |
|
|
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
auto wrap_estimate = [](Estimate e) { |
|
38
|
|
|
|
|
|
|
return Estimate { |
|
39
|
|
|
|
|
|
|
Duration(e.point), |
|
40
|
|
|
|
|
|
|
Duration(e.lower_bound), |
|
41
|
|
|
|
|
|
|
Duration(e.upper_bound), |
|
42
|
|
|
|
|
|
|
e.confidence_interval, |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
0
|
|
|
|
|
|
}; |
|
45
|
0
|
|
|
|
|
|
std::vector samples2; |
|
46
|
0
|
0
|
|
|
|
|
samples2.reserve(samples.size()); |
|
47
|
0
|
0
|
|
|
|
|
std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); |
|
|
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return { |
|
49
|
|
|
|
|
|
|
CATCH_MOVE(samples2), |
|
50
|
|
|
|
|
|
|
wrap_estimate(analysis.mean), |
|
51
|
|
|
|
|
|
|
wrap_estimate(analysis.standard_deviation), |
|
52
|
|
|
|
|
|
|
outliers, |
|
53
|
|
|
|
|
|
|
analysis.outlier_variance, |
|
54
|
0
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
} else { |
|
56
|
0
|
|
|
|
|
|
std::vector samples; |
|
57
|
0
|
0
|
|
|
|
|
samples.reserve(last - first); |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
Duration mean = Duration(0); |
|
60
|
0
|
|
|
|
|
|
int i = 0; |
|
61
|
0
|
0
|
|
|
|
|
for (auto it = first; it < last; ++it, ++i) { |
|
62
|
0
|
0
|
|
|
|
|
samples.push_back(Duration(*it)); |
|
63
|
0
|
|
|
|
|
|
mean += Duration(*it); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
|
mean /= i; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return { |
|
68
|
|
|
|
|
|
|
CATCH_MOVE(samples), |
|
69
|
|
|
|
|
|
|
Estimate{mean, mean, mean, 0.0}, |
|
70
|
|
|
|
|
|
|
Estimate{Duration(0), Duration(0), Duration(0), 0.0}, |
|
71
|
|
|
|
|
|
|
OutlierClassification{}, |
|
72
|
|
|
|
|
|
|
0.0 |
|
73
|
0
|
|
|
|
|
|
}; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
} // namespace Detail |
|
77
|
|
|
|
|
|
|
} // namespace Benchmark |
|
78
|
|
|
|
|
|
|
} // namespace Catch |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#endif // CATCH_ANALYSE_HPP_INCLUDED |