From: Rajat Goel Date: Sat, 22 Sep 2012 10:31:51 +0000 (-0700) Subject: Just trying out one more combination X-Git-Tag: v0.22.0~1173 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1fd9e62b291d1ede7835bb1fa74e090392175b0a;p=folly.git 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 --- 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);