From 1fd9e62b291d1ede7835bb1fa74e090392175b0a Mon Sep 17 00:00:00 2001 From: Rajat Goel Date: Sat, 22 Sep 2012 03:31:51 -0700 Subject: [PATCH] Just trying out one more combination Summary: It seems it is not std::bind which is slow but the construction of std::function from std::bind that is slow. Test Plan: ran benchmarks Reviewed By: delong.j@fb.com FB internal diff: D581967 --- folly/test/function_benchmark/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/folly/test/function_benchmark/main.cpp b/folly/test/function_benchmark/main.cpp index 33610c9d..c345ac78 100644 --- a/folly/test/function_benchmark/main.cpp +++ b/folly/test/function_benchmark/main.cpp @@ -130,6 +130,15 @@ BENCHMARK(std_bind_create_invoke, iters) { } } +// Using std::bind directly to invoke a member function +BENCHMARK(std_bind_direct_invoke, iters) { + TestClass tc; + for (int n = 0; n < iters; ++n) { + auto fn = std::bind(&TestClass::doNothing, &tc); + fn(); + } +} + // Using ScopeGuard to invoke a std::function BENCHMARK(scope_guard_std_function, iters) { std::function fn(doNothing); -- 2.34.1