From 2b8217ce8d11f9bbb78da0482313b4f4496cf5e6 Mon Sep 17 00:00:00 2001 From: Sidharth Guglani Date: Fri, 21 Jun 2019 02:29:53 -0700 Subject: [PATCH] Send measure pass duration Summary: Send measure callback duration time to yoga plugin Reviewed By: davidaurelio Differential Revision: D15917548 fbshipit-source-id: 2c947f14ddbc5932cedd0aab8622260478ec29a6 --- yoga/Yoga.cpp | 15 ++++++++++++++- yoga/event/event.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 0dfcb6e5..3e4ff32e 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "Utils.h" #include "YGNode.h" #include "YGNodePrint.h" @@ -29,6 +30,8 @@ __forceinline const float fmaxf(const float a, const float b) { using namespace facebook::yoga; using detail::Log; +using std::chrono::duration_cast; +using std::chrono::steady_clock; #ifdef ANDROID static int YGAndroidLog( @@ -1626,6 +1629,10 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( ownerWidth), YGDimensionHeight); } else { +#ifdef YG_ENABLE_EVENTS + auto start = steady_clock::now(); +#endif + // Measure the text under the current constraints. const YGSize measuredSize = marker::MarkerSection::wrap( node, @@ -1635,9 +1642,14 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( innerHeight, heightMeasureMode, layoutContext); + layoutMarkerData.measureCallbacks += 1; #ifdef YG_ENABLE_EVENTS + auto end = steady_clock::now(); + auto measureCallbackDuration = + duration_cast>(end - start); + Event::publish( node, {layoutContext, @@ -1646,7 +1658,8 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( innerHeight, heightMeasureMode, measuredSize.width, - measuredSize.height}); + measuredSize.height, + measureCallbackDuration.count()}); #endif node->setLayoutMeasuredDimension( diff --git a/yoga/event/event.h b/yoga/event/event.h index c461de3e..bb659e15 100644 --- a/yoga/event/event.h +++ b/yoga/event/event.h @@ -94,6 +94,7 @@ struct Event::TypedData { YGMeasureMode heightMeasureMode; float measuredWidth; float measuredHeight; + float measureCallbackDuration; }; template <>