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 {
// Default logger
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
......@@ -54,11 +55,11 @@ template<GoogleLoggerStyle> struct GoogleLogger;
* doWork()
* const auto how_long = t.log();
*/
template<
template <
class Logger = GoogleLogger<GoogleLoggerStyle::PRETTY>,
class Clock = std::chrono::high_resolution_clock
> class AutoTimer final {
public:
class Clock = std::chrono::high_resolution_clock>
class AutoTimer final {
public:
explicit AutoTimer(
std::string&& msg = "",
double minTimetoLog = 0.0,
......@@ -82,25 +83,25 @@ public:
return logImpl(Clock::now(), msg);
}
template<typename... Args>
template <typename... Args>
double log(Args&&... args) {
auto now = Clock::now();
return logImpl(now, to<std::string>(std::forward<Args>(args)...));
}
template<typename... Args>
template <typename... Args>
double logFormat(Args&&... args) {
auto now = Clock::now();
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
// to<std::string> or format() in the duration.
double logImpl(std::chrono::time_point<Clock> now, StringPiece msg) {
double duration = std::chrono::duration_cast<std::chrono::duration<double>>(
now - start_
).count();
double duration =
std::chrono::duration_cast<std::chrono::duration<double>>(now - start_)
.count();
if (duration >= minTimeToLog_) {
logger_(msg, duration);
}
......@@ -125,7 +126,7 @@ auto makeAutoTimer(
std::move(msg), minTimeToLog, std::move(logger));
}
template<GoogleLoggerStyle Style>
template <GoogleLoggerStyle Style>
struct GoogleLogger final {
void operator()(StringPiece msg, double sec) const {
if (msg.empty()) {
......@@ -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