2 * Copyright 2011-present 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.
17 #include <folly/test/function_benchmark/benchmark_impl.h>
19 #include <folly/test/function_benchmark/test_functions.h>
22 * These functions are defined in a separate file so that gcc won't be able to
23 * inline them and optimize away the indirect calls.
26 void BM_fn_ptr_invoke_impl(int iters, void (*fn)()) {
27 for (int n = 0; n < iters; ++n) {
32 void BM_std_function_invoke_impl(int iters,
33 const std::function<void()>& fn) {
34 for (int n = 0; n < iters; ++n) {
39 void BM_Function_invoke_impl(int iters,
40 const folly::Function<void() const>& fn) {
41 for (int n = 0; n < iters; ++n) {
46 void BM_mem_fn_invoke_impl(int iters,
48 void (TestClass::*memfn)()) {
49 for (int n = 0; n < iters; ++n) {
54 void BM_virtual_fn_invoke_impl(int iters, VirtualClass* vc) {
55 for (int n = 0; n < iters; ++n) {