From: Pavlo Kushnir Date: Thu, 29 Oct 2015 00:15:19 +0000 (-0700) Subject: Do not set startWork_ in EventBase if time measurement is disabled X-Git-Tag: deprecate-dynamic-initializer~289 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=af3fa519ac83267fabc53d3799a57dab761de0bc;p=folly.git Do not set startWork_ in EventBase if time measurement is disabled Summary: startWork_ is used only if enableTimeMeasurement is set. It gives ~0.5% performance win for mcrouter. Reviewed By: yfeldblum Differential Revision: D2590176 fb-gh-sync-id: 07f2189ebdec751cd0d91d191d8f595780d2808a --- diff --git a/folly/io/async/EventBase.cpp b/folly/io/async/EventBase.cpp index 2ec1e90d..55691b19 100644 --- a/folly/io/async/EventBase.cpp +++ b/folly/io/async/EventBase.cpp @@ -459,12 +459,14 @@ bool EventBase::bumpHandlingTime() { " (loop) latest " << latestLoopCnt_ << " next " << nextLoopCnt_; if(nothingHandledYet()) { latestLoopCnt_ = nextLoopCnt_; - // set the time - startWork_ = std::chrono::duration_cast( - std::chrono::steady_clock::now().time_since_epoch()).count(); + if (enableTimeMeasurement_) { + // set the time + startWork_ = std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()).count(); - VLOG(11) << "EventBase " << this << " " << __PRETTY_FUNCTION__ << - " (loop) startWork_ " << startWork_; + VLOG(11) << "EventBase " << this << " " << __PRETTY_FUNCTION__ << + " (loop) startWork_ " << startWork_; + } return true; } return false;