| 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 |
no outgoing calls
no test coverage detected