MCPcopy Create free account
hub / github.com/Profactor/cv-plot / Chronometer

Class Chronometer

CvPlot/ext/catch2/inc/catch.hpp:6552–6580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6550 } // namespace Detail
6551
6552 struct Chronometer {
6553 public:
6554 template <typename Fun>
6555 void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); }
6556
6557 int runs() const { return k; }
6558
6559 Chronometer(Detail::ChronometerConcept& meter, int k)
6560 : impl(&meter)
6561 , k(k) {}
6562
6563 private:
6564 template <typename Fun>
6565 void measure(Fun&& fun, std::false_type) {
6566 measure([&fun](int) { return fun(); }, std::true_type());
6567 }
6568
6569 template <typename Fun>
6570 void measure(Fun&& fun, std::true_type) {
6571 Detail::optimizer_barrier();
6572 impl->start();
6573 for (int i = 0; i < k; ++i) invoke_deoptimized(fun, i);
6574 impl->finish();
6575 Detail::optimizer_barrier();
6576 }
6577
6578 Detail::ChronometerConcept* impl;
6579 int k;
6580 };
6581 } // namespace Benchmark
6582} // namespace Catch
6583

Callers 2

measure_oneFunction · 0.85
runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected