File indexing completed on 2025-01-30 10:02:47
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_BENCHMARK_STATS_HPP_INCLUDED
0009 #define CATCH_BENCHMARK_STATS_HPP_INCLUDED
0010
0011 #include <catch2/internal/catch_move_and_forward.hpp>
0012 #include <catch2/benchmark/catch_estimate.hpp>
0013 #include <catch2/benchmark/catch_outlier_classification.hpp>
0014
0015
0016 #include <catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp>
0017
0018 #include <string>
0019 #include <vector>
0020
0021 namespace Catch {
0022
0023 struct BenchmarkInfo {
0024 std::string name;
0025 double estimatedDuration;
0026 int iterations;
0027 unsigned int samples;
0028 unsigned int resamples;
0029 double clockResolution;
0030 double clockCost;
0031 };
0032
0033 template <class Duration>
0034 struct BenchmarkStats {
0035 BenchmarkInfo info;
0036
0037 std::vector<Duration> samples;
0038 Benchmark::Estimate<Duration> mean;
0039 Benchmark::Estimate<Duration> standardDeviation;
0040 Benchmark::OutlierClassification outliers;
0041 double outlierVariance;
0042
0043 template <typename Duration2>
0044 operator BenchmarkStats<Duration2>() const {
0045 std::vector<Duration2> samples2;
0046 samples2.reserve(samples.size());
0047 for (auto const& sample : samples) {
0048 samples2.push_back(Duration2(sample));
0049 }
0050 return {
0051 info,
0052 CATCH_MOVE(samples2),
0053 mean,
0054 standardDeviation,
0055 outliers,
0056 outlierVariance,
0057 };
0058 }
0059 };
0060
0061
0062 }
0063
0064 #endif