1 /* 2 * Created by Joachim on 16/04/2019. 3 * Adapted from donated nonius code. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 9 // Benchmark results 10 11 #ifndef TWOBLUECUBES_CATCH_BENCHMARK_RESULTS_HPP_INCLUDED 12 #define TWOBLUECUBES_CATCH_BENCHMARK_RESULTS_HPP_INCLUDED 13 14 #include "catch_clock.hpp" 15 #include "catch_estimate.hpp" 16 #include "catch_outlier_classification.hpp" 17 18 #include <algorithm> 19 #include <vector> 20 #include <string> 21 #include <iterator> 22 23 namespace Catch { 24 namespace Benchmark { 25 template <typename Duration> 26 struct SampleAnalysis { 27 std::vector<Duration> samples; 28 Estimate<Duration> mean; 29 Estimate<Duration> standard_deviation; 30 OutlierClassification outliers; 31 double outlier_variance; 32 33 template <typename Duration2> operator SampleAnalysis<Duration2>Catch::Benchmark::SampleAnalysis34 operator SampleAnalysis<Duration2>() const { 35 std::vector<Duration2> samples2; 36 samples2.reserve(samples.size()); 37 std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); 38 return { 39 std::move(samples2), 40 mean, 41 standard_deviation, 42 outliers, 43 outlier_variance, 44 }; 45 } 46 }; 47 } // namespace Benchmark 48 } // namespace Catch 49 50 #endif // TWOBLUECUBES_CATCH_BENCHMARK_RESULTS_HPP_INCLUDED 51