| 7009 | namespace Detail { |
| 7010 | template <typename Duration, typename Iterator> |
| 7011 | SampleAnalysis<Duration> analyse(const IConfig &cfg, Environment<Duration>, Iterator first, Iterator last) { |
| 7012 | if (!cfg.benchmarkNoAnalysis()) { |
| 7013 | std::vector<double> samples; |
| 7014 | samples.reserve(last - first); |
| 7015 | std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); |
| 7016 | |
| 7017 | auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); |
| 7018 | auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); |
| 7019 | |
| 7020 | auto wrap_estimate = [](Estimate<double> e) { |
| 7021 | return Estimate<Duration> { |
| 7022 | Duration(e.point), |
| 7023 | Duration(e.lower_bound), |
| 7024 | Duration(e.upper_bound), |
| 7025 | e.confidence_interval, |
| 7026 | }; |
| 7027 | }; |
| 7028 | std::vector<Duration> samples2; |
| 7029 | samples2.reserve(samples.size()); |
| 7030 | std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); |
| 7031 | return { |
| 7032 | std::move(samples2), |
| 7033 | wrap_estimate(analysis.mean), |
| 7034 | wrap_estimate(analysis.standard_deviation), |
| 7035 | outliers, |
| 7036 | analysis.outlier_variance, |
| 7037 | }; |
| 7038 | } else { |
| 7039 | std::vector<Duration> samples; |
| 7040 | samples.reserve(last - first); |
| 7041 | |
| 7042 | Duration mean = Duration(0); |
| 7043 | int i = 0; |
| 7044 | for (auto it = first; it < last; ++it, ++i) { |
| 7045 | samples.push_back(Duration(*it)); |
| 7046 | mean += Duration(*it); |
| 7047 | } |
| 7048 | mean /= i; |
| 7049 | |
| 7050 | return { |
| 7051 | std::move(samples), |
| 7052 | Estimate<Duration>{mean, mean, mean, 0.0}, |
| 7053 | Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0}, |
| 7054 | OutlierClassification{}, |
| 7055 | 0.0 |
| 7056 | }; |
| 7057 | } |
| 7058 | } |
| 7059 | } // namespace Detail |
| 7060 | } // namespace Benchmark |
| 7061 | } // namespace Catch |
no test coverage detected