MCPcopy Create free account
hub / github.com/apache/trafficserver / Chronometer

Class Chronometer

lib/catch2/catch.hpp:6617–6645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6615 } // namespace Detail
6616
6617 struct Chronometer {
6618 public:
6619 template <typename Fun>
6620 void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); }
6621
6622 int runs() const { return k; }
6623
6624 Chronometer(Detail::ChronometerConcept& meter, int k)
6625 : impl(&meter)
6626 , k(k) {}
6627
6628 private:
6629 template <typename Fun>
6630 void measure(Fun&& fun, std::false_type) {
6631 measure([&fun](int) { return fun(); }, std::true_type());
6632 }
6633
6634 template <typename Fun>
6635 void measure(Fun&& fun, std::true_type) {
6636 Detail::optimizer_barrier();
6637 impl->start();
6638 for (int i = 0; i < k; ++i) invoke_deoptimized(fun, i);
6639 impl->finish();
6640 Detail::optimizer_barrier();
6641 }
6642
6643 Detail::ChronometerConcept* impl;
6644 int k;
6645 };
6646 } // namespace Benchmark
6647} // namespace Catch
6648

Callers 2

measure_oneFunction · 0.85
runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected