BM_std_function_invoke_impl(iters, doNothing);
}
+// Invoking a function through a folly::Function object
+BENCHMARK(Function_invoke, iters) {
+ BM_Function_invoke_impl(iters, doNothing);
+}
+
// Invoking a member function through a member function pointer
BENCHMARK(mem_fn_invoke, iters) {
TestClass tc;
}
}
+// Creating a folly::Function object from a function pointer, and
+// invoking it
+BENCHMARK(Function_create_invoke, iters) {
+ for (size_t n = 0; n < iters; ++n) {
+ folly::Function<void()> fn = doNothing;
+ fn();
+ }
+}
+
// Creating a pointer-to-member and invoking it
BENCHMARK(mem_fn_create_invoke, iters) {
TestClass tc;
}
}
+// Using ScopeGuard to invoke a folly::Function,
+// but create the ScopeGuard with an rvalue to a folly::Function
+BENCHMARK(scope_guard_Function_rvalue, iters) {
+ for (size_t n = 0; n < iters; ++n) {
+ ScopeGuard g = makeGuard(folly::Function<void()>(doNothing));
+ }
+}
+
// Using ScopeGuard to invoke a function pointer
BENCHMARK(scope_guard_fn_ptr, iters) {
for (size_t n = 0; n < iters; ++n) {