proxygen
benchmark_impl.h
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 
17 #pragma once
18 
19 #include <functional>
20 
21 #include <folly/Function.h>
22 
23 class TestClass;
24 class VirtualClass;
25 
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);
29  int iters,
30  const folly::Function<void() const>& fn);
32  int iters,
33  TestClass* tc,
34  void (TestClass::*memfn)());
35 void BM_virtual_fn_invoke_impl(int iters, VirtualClass* vc);
36 
37 // Inlined version of BM_fn_ptr_invoke_impl().
38 // The compiler could potentially even optimize the call to the function
39 // pointer if it is a constexpr.
40 inline void BM_fn_ptr_invoke_inlined_impl(int iters, void (*fn)()) {
41  for (int n = 0; n < iters; ++n) {
42  fn();
43  }
44 }
45 
46 // Invoke a function object as a template parameter.
47 // This can be used to directly invoke lambda functions
48 template <typename T>
49 void BM_invoke_fn_template_impl(int iters, const T& fn) {
50  for (int n = 0; n < iters; ++n) {
51  fn();
52  }
53 }
#define T(v)
Definition: http_parser.c:233
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_mem_fn_invoke_impl(int iters, TestClass *tc, void(TestClass::*memfn)())
void BM_std_function_invoke_impl(int iters, const std::function< void()> &fn)
static bool tc
void BM_fn_ptr_invoke_inlined_impl(int iters, void(*fn)())
void BM_invoke_fn_template_impl(int iters, const T &fn)
void BM_fn_ptr_invoke_impl(int iters, void(*fn)())