MCPcopy Create free account
hub / github.com/Dobiasd/FunctionalPlus / bench_function_impl

Class bench_function_impl

include/fplus/benchmark_session.hpp:84–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82namespace internal {
83 template <typename Fn>
84 class bench_function_impl {
85 public:
86 explicit bench_function_impl(
87 benchmark_session& benchmark_sess,
88 FunctionName function_name,
89 Fn fn)
90 : benchmark_session_(benchmark_sess)
91 , function_name_(function_name)
92 , fn_(fn) {};
93
94 template <typename... Args>
95 auto operator()(Args&&... args)
96 {
97 return _bench_result(std::forward<Args>(args)...);
98 }
99
100 private:
101 template <typename... Args>
102 auto _bench_result(Args&&... args)
103 {
104 fplus::stopwatch timer;
105 auto r = fn_(std::forward<Args>(args)...);
106 benchmark_session_.store_one_time(function_name_, timer.elapsed());
107 return r;
108 }
109
110 benchmark_session& benchmark_session_;
111 FunctionName function_name_;
112 Fn fn_;
113 };
114
115 template <typename Fn>
116 class bench_void_function_impl {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected