File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1010#include < string.h>
1111#include < algorithm>
1212#include < memory>
13+ #include < chrono>
1314#include " Utils.h"
1415#include " YGNode.h"
1516#include " YGNodePrint.h"
@@ -29,6 +30,8 @@ __forceinline const float fmaxf(const float a, const float b) {
2930
3031using namespace facebook ::yoga;
3132using detail::Log;
33+ using std::chrono::duration_cast;
34+ using std::chrono::steady_clock;
3235
3336#ifdef ANDROID
3437static int YGAndroidLog (
@@ -1626,6 +1629,10 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
16261629 ownerWidth),
16271630 YGDimensionHeight);
16281631 } else {
1632+ #ifdef YG_ENABLE_EVENTS
1633+ auto start = steady_clock::now ();
1634+ #endif
1635+
16291636 // Measure the text under the current constraints.
16301637 const YGSize measuredSize = marker::MarkerSection<YGMarkerMeasure>::wrap (
16311638 node,
@@ -1635,9 +1642,14 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
16351642 innerHeight,
16361643 heightMeasureMode,
16371644 layoutContext);
1645+
16381646 layoutMarkerData.measureCallbacks += 1 ;
16391647
16401648#ifdef YG_ENABLE_EVENTS
1649+ auto end = steady_clock::now ();
1650+ auto measureCallbackDuration =
1651+ duration_cast<std::chrono::duration<float , std::milli>>(end - start);
1652+
16411653 Event::publish<Event::NodeMeasure>(
16421654 node,
16431655 {layoutContext,
@@ -1646,7 +1658,8 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
16461658 innerHeight,
16471659 heightMeasureMode,
16481660 measuredSize.width ,
1649- measuredSize.height });
1661+ measuredSize.height ,
1662+ measureCallbackDuration.count ()});
16501663#endif
16511664
16521665 node->setLayoutMeasuredDimension (
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ struct Event::TypedData<Event::NodeMeasure> {
9494 YGMeasureMode heightMeasureMode;
9595 float measuredWidth;
9696 float measuredHeight;
97+ float measureCallbackDuration;
9798};
9899
99100template <>
You can’t perform that action at this time.
0 commit comments