Struct Chronometer

Synopsis

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

struct Chronometer

Description

No description yet.

Mentioned in

Methods

Chronometer
measure

Mentioned in

runs

Mentioned in

Source

Lines 39-67 in include/internal/benchmark/catch_chronometer.hpp.

struct Chronometer {
public:
    template <typename Fun>
    void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); }
    int runs() const { return k; }
    Chronometer(Detail::ChronometerConcept& meter, int k)
        : impl(&meter)
        , k(k) {}
private:
    template <typename Fun>
    void measure(Fun&& fun, std::false_type) {
        measure([&fun](int) { return fun(); }, std::true_type());
    }
    template <typename Fun>
    void measure(Fun&& fun, std::true_type) {
        Detail::optimizer_barrier();
        impl->start();
        for (int i = 0; i < k; ++i) invoke_deoptimized(fun, i);
        impl->finish();
        Detail::optimizer_barrier();
    }
    Detail::ChronometerConcept* impl;
    int k;
};





Add Discussion as Guest

Log in