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
}
}
+// 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<void()> fn(doNothing);