[Webkit-unassigned] [Bug 259538] Potential Optimization - Avoid multiple recursions through the tree when calculating percent height
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Jan 24 16:08:03 PST 2024
https://bugs.webkit.org/show_bug.cgi?id=259538
--- Comment #3 from Ahmad Saleem <ahmad.saleem792 at gmail.com> ---
This compiles:
LayoutUnit RenderBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight, std::optional<LayoutUnit> intrinsicContentHeight) const
{
// If the min/max height and logical height are both percentages we take advantage of already knowing the current resolved percentage height
// to avoid recursing up through our containing blocks again to determine it.
const RenderStyle& styleToUse = style();
if (!styleToUse.logicalMaxHeight().isUndefined()) {
if (styleToUse.logicalMaxHeight().isPercent() && styleToUse.logicalHeight().isPercent()) {
auto availableLogicalHeight = logicalHeight / (styleToUse.logicalHeight().value() * 100);
logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.logicalMaxHeight(), availableLogicalHeight));
} else {
std::optional<LayoutUnit> maxH = computeContentLogicalHeight(MaxSize, styleToUse.logicalMaxHeight(), intrinsicContentHeight);
logicalHeight = std::min(logicalHeight, maxH.value());
}
}
if (styleToUse.logicalMinHeight().isPercent() && styleToUse.logicalHeight().isPercent()) {
auto availableLogicalHeight = logicalHeight / (styleToUse.logicalHeight().value() * 100);
logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logicalMinHeight(), availableLogicalHeight));
} else {
if (std::optional<LayoutUnit> computedContentLogicalHeight = computeContentLogicalHeight(MinSize, styleToUse.logicalMinHeight(), intrinsicContentHeight))
return std::max(logicalHeight, computedContentLogicalHeight.value());
}
return logicalHeight;
}
__
Plus with this I get following in JSFiddle:
Running 20 times
Ignoring warm-up run (4405.269761606022 runs/s)
4416.562107904646 runs/s
4416.56210790464 runs/s
4400.000000000003 runs/s
4433.249370277081 runs/s
4383.561643835616 runs/s
4422.110552763819 runs/s
4444.44444444445 runs/s
4438.839848675909 runs/s
4416.562107904652 runs/s
4405.506883604496 runs/s
4422.110552763819 runs/s
4438.839848675914 runs/s
4394.5068664169785 runs/s
4433.249370277088 runs/s
4416.562107904622 runs/s
4433.249370277088 runs/s
4438.839848675914 runs/s
4422.110552763819 runs/s
4427.672955974843 runs/s
4405.506883604486 runs/s
Description: Measures performance of nested divs with percent values for height and max-height.
Time:
values 4416.562107904646, 4416.56210790464, 4400.000000000003, 4433.249370277081, 4383.561643835616, 4422.110552763819, 4444.44444444445, 4438.839848675909, 4416.562107904652, 4405.506883604496, 4422.110552763819, 4438.839848675914, 4394.5068664169785, 4433.249370277088, 4416.562107904622, 4433.249370277088, 4438.839848675914, 4422.110552763819, 4427.672955974843, 4405.506883604486 runs/s
avg 4420.502371232495 runs/s
median 4422.110552763819 runs/s
stdev 16.38550213770903 runs/s
min 4383.561643835616 runs/s
max 4444.44444444445 runs/s
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240125/c35c8652/attachment-0001.htm>
More information about the webkit-unassigned
mailing list