Make AutoTimer usable with Closures
authorAravind Anbudurai <aru7@fb.com>
Thu, 30 Jun 2016 07:48:22 +0000 (00:48 -0700)
committerFacebook Github Bot 7 <facebook-github-bot-7-bot@fb.com>
Thu, 30 Jun 2016 07:53:21 +0000 (00:53 -0700)
commit3f09eed1c170722897cfb988bf0702c35b67b2ec
treecf07adc0432c556327ae614b043a9cbc910598f9
parent75e5507cbfe7ef5a448375e9908e10864b506b05
Make AutoTimer usable with Closures

Summary:
Currently, AutoTimer works only with FunctionObjects that are default constructible because it constructs Logger each time it needs to log. This diff makes AutoTimer work with closures too. This will help in making AutoTimer more flexible because the user can capture necessary dependencies in the lambda.

This diff also cleans up the constructors on AutoTimer by making it take an
std::string&& instead of Args... that is passed into folly::to<..>. Although
this makes the instantiation a bit harder, the simplicity of constructor seems
worth it.

This also refactors the callsites of setMinLogTime to directly pass the
value into the ctor and changes callsites on fbcode

Reviewed By: yfeldblum

Differential Revision: D3487868

fbshipit-source-id: 52fa1099a5e39b791972cc0d3f678d44ea4ba288
folly/experimental/AutoTimer.h
folly/experimental/test/AutoTimerTest.cpp