Function run

Synopsis

#include <include/internal/benchmark/catch_benchmark.hpp>

template <typename Clock = default_clock>
void run()

Description

No description yet.

Source

Lines 53-89 in include/internal/benchmark/catch_benchmark.hpp.

template <typename Clock = default_clock>
void run() {
    IConfigPtr cfg = getCurrentContext().getConfig();
    auto env = Detail::measure_environment<Clock>();
    getResultCapture().benchmarkPreparing(name);
    CATCH_TRY{
        auto plan = user_code([&] {
            return prepare<Clock>(*cfg, env);
        });
        BenchmarkInfo info {
            name,
            plan.estimated_duration.count(),
            plan.iterations_per_sample,
            cfg->benchmarkSamples(),
            cfg->benchmarkResamples(),
            env.clock_resolution.mean.count(),
            env.clock_cost.mean.count()
        };
        getResultCapture().benchmarkStarting(info);
        auto samples = user_code([&] {
            return plan.template run<Clock>(*cfg, env);
        });
        auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end());
        BenchmarkStats<FloatDuration<Clock>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
        getResultCapture().benchmarkEnded(stats);
    } CATCH_CATCH_ALL{
        if (translateActiveException() != Detail::benchmarkErrorMsg) // benchmark errors have been reported, otherwise rethrow.
            std::rethrow_exception(std::current_exception());
    }
}





Add Discussion as Guest

Log in