2 * Copyright 2017 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <folly/Function.h>
26 void BM_fn_ptr_invoke_impl(int iters, void (*fn)());
27 void BM_std_function_invoke_impl(int iters, const std::function<void()>& fn);
28 void BM_Function_invoke_impl(int iters,
29 const folly::Function<void() const>& fn);
30 void BM_mem_fn_invoke_impl(int iters,
32 void (TestClass::*memfn)());
33 void BM_virtual_fn_invoke_impl(int iters, VirtualClass* vc);
35 // Inlined version of BM_fn_ptr_invoke_impl().
36 // The compiler could potentially even optimize the call to the function
37 // pointer if it is a constexpr.
38 inline void BM_fn_ptr_invoke_inlined_impl(int iters, void (*fn)()) {
39 for (int n = 0; n < iters; ++n) {
44 // Invoke a function object as a template parameter.
45 // This can be used to directly invoke lambda functions
47 void BM_invoke_fn_template_impl(int iters, const T& fn) {
48 for (int n = 0; n < iters; ++n) {