From 1c1a6b4577cf7ad7526dd7386f5becd2ee8b765c Mon Sep 17 00:00:00 2001 From: Aravind Anbudurai Date: Thu, 30 Jun 2016 20:52:41 -0700 Subject: [PATCH] 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 --- folly/experimental/AutoTimer.h | 63 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/folly/experimental/AutoTimer.h b/folly/experimental/AutoTimer.h index 7e0f2909..20c5156d 100644 --- a/folly/experimental/AutoTimer.h +++ b/folly/experimental/AutoTimer.h @@ -28,7 +28,8 @@ namespace folly { // Default logger enum class GoogleLoggerStyle { SECONDS, PRETTY }; -template struct GoogleLogger; +template +struct GoogleLogger; /** * Automatically times a block of code, printing a specified log message on @@ -54,53 +55,53 @@ template struct GoogleLogger; * doWork() * const auto how_long = t.log(); */ -template< - class Logger = GoogleLogger, - class Clock = std::chrono::high_resolution_clock -> class AutoTimer final { -public: - explicit AutoTimer( - std::string&& msg = "", - double minTimetoLog = 0.0, - Logger&& logger = Logger()) - : destructionMessage_(std::move(msg)), - minTimeToLog_(minTimetoLog), - logger_(std::move(logger)) {} - - // It doesn't really make sense to copy AutoTimer - // Movable to make sure the helper method for creating an AutoTimer works. - AutoTimer(const AutoTimer&) = delete; - AutoTimer(AutoTimer&&) = default; - AutoTimer& operator=(const AutoTimer&) = delete; - AutoTimer& operator=(AutoTimer&&) = default; - - ~AutoTimer() { - log(destructionMessage_); +template < + class Logger = GoogleLogger, + class Clock = std::chrono::high_resolution_clock> +class AutoTimer final { + public: + explicit AutoTimer( + std::string&& msg = "", + double minTimetoLog = 0.0, + Logger&& logger = Logger()) + : destructionMessage_(std::move(msg)), + minTimeToLog_(minTimetoLog), + logger_(std::move(logger)) {} + + // It doesn't really make sense to copy AutoTimer + // Movable to make sure the helper method for creating an AutoTimer works. + AutoTimer(const AutoTimer&) = delete; + AutoTimer(AutoTimer&&) = default; + AutoTimer& operator=(const AutoTimer&) = delete; + AutoTimer& operator=(AutoTimer&&) = default; + + ~AutoTimer() { + log(destructionMessage_); } double log(StringPiece msg = "") { return logImpl(Clock::now(), msg); } - template + template double log(Args&&... args) { auto now = Clock::now(); return logImpl(now, to(std::forward(args)...)); } - template + template double logFormat(Args&&... args) { auto now = Clock::now(); return logImpl(now, format(std::forward(args)...).str()); } -private: + private: // We take in the current time so that we don't measure time to call // to or format() in the duration. double logImpl(std::chrono::time_point now, StringPiece msg) { - double duration = std::chrono::duration_cast>( - now - start_ - ).count(); + double duration = + std::chrono::duration_cast>(now - start_) + .count(); if (duration >= minTimeToLog_) { logger_(msg, duration); } @@ -125,7 +126,7 @@ auto makeAutoTimer( std::move(msg), minTimeToLog, std::move(logger)); } -template +template struct GoogleLogger final { void operator()(StringPiece msg, double sec) const { if (msg.empty()) { @@ -138,6 +139,4 @@ struct GoogleLogger final { } } }; - - } -- 2.34.1