| 7235 | namespace Detail { |
| 7236 | template <typename Duration, typename Iterator> |
| 7237 | SampleAnalysis<Duration> analyse(const IConfig &cfg, Environment<Duration>, Iterator first, Iterator last) { |
| 7238 | if (!cfg.benchmarkNoAnalysis()) { |
| 7239 | std::vector<double> samples; |
| 7240 | samples.reserve(last - first); |
| 7241 | std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); |
| 7242 | |
| 7243 | auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); |
| 7244 | auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); |
| 7245 | |
| 7246 | auto wrap_estimate = [](Estimate<double> e) { |
| 7247 | return Estimate<Duration> { |
| 7248 | Duration(e.point), |
| 7249 | Duration(e.lower_bound), |
| 7250 | Duration(e.upper_bound), |
| 7251 | e.confidence_interval, |
| 7252 | }; |
| 7253 | }; |
| 7254 | std::vector<Duration> samples2; |
| 7255 | samples2.reserve(samples.size()); |
| 7256 | std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); |
| 7257 | return { |
| 7258 | std::move(samples2), |
| 7259 | wrap_estimate(analysis.mean), |
| 7260 | wrap_estimate(analysis.standard_deviation), |
| 7261 | outliers, |
| 7262 | analysis.outlier_variance, |
| 7263 | }; |
| 7264 | } else { |
| 7265 | std::vector<Duration> samples; |
| 7266 | samples.reserve(last - first); |
| 7267 | |
| 7268 | Duration mean = Duration(0); |
| 7269 | int i = 0; |
| 7270 | for (auto it = first; it < last; ++it, ++i) { |
| 7271 | samples.push_back(Duration(*it)); |
| 7272 | mean += Duration(*it); |
| 7273 | } |
| 7274 | mean /= i; |
| 7275 | |
| 7276 | return { |
| 7277 | std::move(samples), |
| 7278 | Estimate<Duration>{mean, mean, mean, 0.0}, |
| 7279 | Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0}, |
| 7280 | OutlierClassification{}, |
| 7281 | 0.0 |
| 7282 | }; |
| 7283 | } |
| 7284 | } |
| 7285 | } // namespace Detail |
| 7286 | } // namespace Benchmark |
| 7287 | } // namespace Catch |
no test coverage detected