count cache hits
Summary: @public Adds cache hit counts to layout stats. Reviewed By: SidharthGuglani Differential Revision: D13844022 fbshipit-source-id: 906b4ec5fe3314287911cee2c37d77c4aac76455
This commit is contained in:
committed by
Facebook Github Bot
parent
460370b7d3
commit
59446294b3
@@ -125,6 +125,37 @@ TEST_F(MarkerTest, layout_marker_counts_multi_node_layout) {
|
|||||||
(YGMarkerLayoutData{.layouts = 3, .measures = 4}));
|
(YGMarkerLayoutData{.layouts = 3, .measures = 4}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MarkerTest, layout_marker_counts_cache_hits_single_node_layout) {
|
||||||
|
auto root = makeNode();
|
||||||
|
calculateLayout(root);
|
||||||
|
|
||||||
|
calculateLayout(root);
|
||||||
|
|
||||||
|
ASSERT_EQ(
|
||||||
|
markerCookie.end.markerData.layout,
|
||||||
|
(YGMarkerLayoutData{.layouts = 0,
|
||||||
|
.measures = 0,
|
||||||
|
.cachedLayouts = 1,
|
||||||
|
.cachedMeasures = 0}));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(MarkerTest, layout_marker_counts_cache_hits_multi_node_layout) {
|
||||||
|
auto root = makeNode();
|
||||||
|
auto childA = addChild(root);
|
||||||
|
auto childB = addChild(root);
|
||||||
|
calculateLayout(root, 987, 654);
|
||||||
|
calculateLayout(root, 123, 456);
|
||||||
|
|
||||||
|
calculateLayout(root, 987, 654);
|
||||||
|
|
||||||
|
ASSERT_EQ(
|
||||||
|
markerCookie.end.markerData.layout,
|
||||||
|
(YGMarkerLayoutData{.layouts = 3,
|
||||||
|
.measures = 0,
|
||||||
|
.cachedLayouts = 0,
|
||||||
|
.cachedMeasures = 4}));
|
||||||
|
}
|
||||||
|
|
||||||
void* MarkerTest::startMarker(
|
void* MarkerTest::startMarker(
|
||||||
YGMarker marker,
|
YGMarker marker,
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
@@ -179,10 +210,14 @@ decltype(MarkerTest::markerCookie) MarkerTest::markerCookie = {};
|
|||||||
} // namespace facebook
|
} // namespace facebook
|
||||||
|
|
||||||
bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
||||||
return lhs.layouts == rhs.layouts && lhs.measures == rhs.measures;
|
return lhs.layouts == rhs.layouts && lhs.measures == rhs.measures &&
|
||||||
|
lhs.cachedLayouts == rhs.cachedLayouts &&
|
||||||
|
lhs.cachedMeasures == rhs.cachedMeasures;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintTo(const YGMarkerLayoutData data, std::ostream* os) {
|
void PrintTo(const YGMarkerLayoutData data, std::ostream* os) {
|
||||||
*os << "YGMarkerLayoutData{ layouts = " << data.layouts
|
*os << "YGMarkerLayoutData{ layouts = " << data.layouts
|
||||||
<< ", measures = " << data.measures << " }";
|
<< ", measures = " << data.measures
|
||||||
|
<< ", cachedLayouts = " << data.cachedLayouts
|
||||||
|
<< ", cachedMeasures = " << data.cachedMeasures << " }";
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,8 @@ typedef YG_ENUM_BEGIN(YGMarker){
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
int layouts;
|
int layouts;
|
||||||
int measures;
|
int measures;
|
||||||
|
int cachedLayouts;
|
||||||
|
int cachedMeasures;
|
||||||
} YGMarkerLayoutData;
|
} YGMarkerLayoutData;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
|
@@ -3803,6 +3803,9 @@ bool YGLayoutNodeInternal(
|
|||||||
layout->measuredDimensions[YGDimensionHeight] =
|
layout->measuredDimensions[YGDimensionHeight] =
|
||||||
cachedResults->computedHeight;
|
cachedResults->computedHeight;
|
||||||
|
|
||||||
|
(performLayout ? layoutMarkerData.cachedLayouts
|
||||||
|
: layoutMarkerData.cachedMeasures) += 1;
|
||||||
|
|
||||||
if (gPrintChanges && gPrintSkips) {
|
if (gPrintChanges && gPrintSkips) {
|
||||||
YGLog(
|
YGLog(
|
||||||
node,
|
node,
|
||||||
|
Reference in New Issue
Block a user