Do not set startWork_ in EventBase if time measurement is disabled
authorPavlo Kushnir <pavlo@fb.com>
Thu, 29 Oct 2015 00:15:19 +0000 (17:15 -0700)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Thu, 29 Oct 2015 01:20:21 +0000 (18:20 -0700)
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

folly/io/async/EventBase.cpp

index 2ec1e90dcc5861e3a1a3a56363d1dff8b250c105..55691b19db7173d9d758de31422e0dc7d71a00b2 100644 (file)
@@ -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::microseconds>(
-      std::chrono::steady_clock::now().time_since_epoch()).count();
+    if (enableTimeMeasurement_) {
+      // set the time
+      startWork_ = std::chrono::duration_cast<std::chrono::microseconds>(
+        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;