proxygen
benchmark_impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-present Facebook, Inc.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
18 
20 
21 /*
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.
24  */
25 
26 void BM_fn_ptr_invoke_impl(int iters, void (*fn)()) {
27  for (int n = 0; n < iters; ++n) {
28  fn();
29  }
30 }
31 
32 void BM_std_function_invoke_impl(int iters, const std::function<void()>& fn) {
33  for (int n = 0; n < iters; ++n) {
34  fn();
35  }
36 }
37 
39  int iters,
40  const folly::Function<void() const>& fn) {
41  for (int n = 0; n < iters; ++n) {
42  fn();
43  }
44 }
45 
47  int iters,
48  TestClass* tc,
49  void (TestClass::*memfn)()) {
50  for (int n = 0; n < iters; ++n) {
51  (tc->*memfn)();
52  }
53 }
54 
56  for (int n = 0; n < iters; ++n) {
57  vc->doNothing();
58  }
59 }
void BM_Function_invoke_impl(int iters, const folly::Function< void() const > &fn)
void BM_virtual_fn_invoke_impl(int iters, VirtualClass *vc)
void BM_fn_ptr_invoke_impl(int iters, void(*fn)())
virtual void doNothing()
static bool tc
void BM_mem_fn_invoke_impl(int iters, TestClass *tc, void(TestClass::*memfn)())
void BM_std_function_invoke_impl(int iters, const std::function< void()> &fn)