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 <>