| 7165 | namespace Detail { |
| 7166 | template <typename Duration, typename Iterator> |
| 7167 | SampleAnalysis<Duration> analyse(const IConfig &cfg, Environment<Duration>, Iterator first, Iterator last) { |
| 7168 | if (!cfg.benchmarkNoAnalysis()) { |
| 7169 | std::vector<double> samples; |
| 7170 | samples.reserve(last - first); |
| 7171 | std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); |
| 7172 | |
| 7173 | auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); |
| 7174 | auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); |
| 7175 | |
| 7176 | auto wrap_estimate = [](Estimate<double> e) { |
| 7177 | return Estimate<Duration> { |
| 7178 | Duration(e.point), |
| 7179 | Duration(e.lower_bound), |
| 7180 | Duration(e.upper_bound), |
| 7181 | e.confidence_interval, |
| 7182 | }; |
| 7183 | }; |
| 7184 | std::vector<Duration> samples2; |
| 7185 | samples2.reserve(samples.size()); |
| 7186 | std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); |
| 7187 | return { |
| 7188 | std::move(samples2), |
| 7189 | wrap_estimate(analysis.mean), |
| 7190 | wrap_estimate(analysis.standard_deviation), |
| 7191 | outliers, |
| 7192 | analysis.outlier_variance, |
| 7193 | }; |
| 7194 | } else { |
| 7195 | std::vector<Duration> samples; |
| 7196 | samples.reserve(last - first); |
| 7197 | |
| 7198 | Duration mean = Duration(0); |
| 7199 | int i = 0; |
| 7200 | for (auto it = first; it < last; ++it, ++i) { |
| 7201 | samples.push_back(Duration(*it)); |
| 7202 | mean += Duration(*it); |
| 7203 | } |
| 7204 | mean /= i; |
| 7205 | |
| 7206 | return { |
| 7207 | std::move(samples), |
| 7208 | Estimate<Duration>{mean, mean, mean, 0.0}, |
| 7209 | Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0}, |
| 7210 | OutlierClassification{}, |
| 7211 | 0.0 |
| 7212 | }; |
| 7213 | } |
| 7214 | } |
| 7215 | } // namespace Detail |
| 7216 | } // namespace Benchmark |
| 7217 | } // namespace Catch |
no test coverage detected