Commit 1c1a6b45 authored by Aravind Anbudurai's avatar Aravind Anbudurai Committed by Facebook Github Bot 7

clang-format AutoTimer.h

Summary:
Somehow the formatting is messed up and it was triggering my OCD.
Sending a diff before I go crazy

Depends on D3506557

Reviewed By: yfeldblum

Differential Revision: D3506618

fbshipit-source-id: 218ce2100cc45c5017328e97344029061fe2eff5
parent 1880e851
...@@ -28,7 +28,8 @@ namespace folly { ...@@ -28,7 +28,8 @@ namespace folly {
// Default logger // Default logger
enum class GoogleLoggerStyle { SECONDS, PRETTY }; enum class GoogleLoggerStyle { SECONDS, PRETTY };
template<GoogleLoggerStyle> struct GoogleLogger; template <GoogleLoggerStyle>
struct GoogleLogger;
/** /**
* Automatically times a block of code, printing a specified log message on * Automatically times a block of code, printing a specified log message on
...@@ -54,11 +55,11 @@ template<GoogleLoggerStyle> struct GoogleLogger; ...@@ -54,11 +55,11 @@ template<GoogleLoggerStyle> struct GoogleLogger;
* doWork() * doWork()
* const auto how_long = t.log(); * const auto how_long = t.log();
*/ */
template< template <
class Logger = GoogleLogger<GoogleLoggerStyle::PRETTY>, class Logger = GoogleLogger<GoogleLoggerStyle::PRETTY>,
class Clock = std::chrono::high_resolution_clock class Clock = std::chrono::high_resolution_clock>
> class AutoTimer final { class AutoTimer final {
public: public:
explicit AutoTimer( explicit AutoTimer(
std::string&& msg = "", std::string&& msg = "",
double minTimetoLog = 0.0, double minTimetoLog = 0.0,
...@@ -82,25 +83,25 @@ public: ...@@ -82,25 +83,25 @@ public:
return logImpl(Clock::now(), msg); return logImpl(Clock::now(), msg);
} }
template<typename... Args> template <typename... Args>
double log(Args&&... args) { double log(Args&&... args) {
auto now = Clock::now(); auto now = Clock::now();
return logImpl(now, to<std::string>(std::forward<Args>(args)...)); return logImpl(now, to<std::string>(std::forward<Args>(args)...));
} }
template<typename... Args> template <typename... Args>
double logFormat(Args&&... args) { double logFormat(Args&&... args) {
auto now = Clock::now(); auto now = Clock::now();
return logImpl(now, format(std::forward<Args>(args)...).str()); return logImpl(now, format(std::forward<Args>(args)...).str());
} }
private: private:
// We take in the current time so that we don't measure time to call // We take in the current time so that we don't measure time to call
// to<std::string> or format() in the duration. // to<std::string> or format() in the duration.
double logImpl(std::chrono::time_point<Clock> now, StringPiece msg) { double logImpl(std::chrono::time_point<Clock> now, StringPiece msg) {
double duration = std::chrono::duration_cast<std::chrono::duration<double>>( double duration =
now - start_ std::chrono::duration_cast<std::chrono::duration<double>>(now - start_)
).count(); .count();
if (duration >= minTimeToLog_) { if (duration >= minTimeToLog_) {
logger_(msg, duration); logger_(msg, duration);
} }
...@@ -125,7 +126,7 @@ auto makeAutoTimer( ...@@ -125,7 +126,7 @@ auto makeAutoTimer(
std::move(msg), minTimeToLog, std::move(logger)); std::move(msg), minTimeToLog, std::move(logger));
} }
template<GoogleLoggerStyle Style> template <GoogleLoggerStyle Style>
struct GoogleLogger final { struct GoogleLogger final {
void operator()(StringPiece msg, double sec) const { void operator()(StringPiece msg, double sec) const {
if (msg.empty()) { if (msg.empty()) {
...@@ -138,6 +139,4 @@ struct GoogleLogger final { ...@@ -138,6 +139,4 @@ struct GoogleLogger final {
} }
} }
}; };
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment