From c16fadb7c34abdcf96520561f1aec8a15a55968d Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 29 Jan 2019 14:44:55 -0800 Subject: [PATCH] Track how much measure cache entries are used Summary: @public Adds the maximum number of measure cache entries in use to the metrics for `YGMarkerLayout` Reviewed By: SidharthGuglani Differential Revision: D13844731 fbshipit-source-id: fa66dbf1b7a1799494f72ecc17dfaef04d0b56e4 --- ReactCommon/yoga/yoga/YGMarker.h | 1 + ReactCommon/yoga/yoga/Yoga.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ReactCommon/yoga/yoga/YGMarker.h b/ReactCommon/yoga/yoga/YGMarker.h index 60de5120a99..63f2c40fba9 100644 --- a/ReactCommon/yoga/yoga/YGMarker.h +++ b/ReactCommon/yoga/yoga/YGMarker.h @@ -20,6 +20,7 @@ typedef YG_ENUM_BEGIN(YGMarker){ typedef struct { int layouts; int measures; + int maxMeasureCache; int cachedLayouts; int cachedMeasures; } YGMarkerLayoutData; diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 9ae16401e06..0d576d59b90 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -3889,6 +3889,11 @@ bool YGLayoutNodeInternal( layout->lastOwnerDirection = ownerDirection; if (cachedResults == nullptr) { + if (layout->nextCachedMeasurementsIndex + 1 > + (uint32_t) layoutMarkerData.maxMeasureCache) { + layoutMarkerData.maxMeasureCache = + layout->nextCachedMeasurementsIndex + 1; + } if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) { if (gPrintChanges) { YGLog(node, YGLogLevelVerbose, "Out of cache entries!\n");