Commit 0979d604 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Add a performance test to measure MapToVisualRectInAncestorSpace.

The test compares two versions of MapToVisualRectInAncestorSpace,
one with GeometryMapper and one without.

Bug: 831762
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: If385614a90d5276f1e995f268e81c04cc72abeff
Reviewed-on: https://chromium-review.googlesource.com/1065174Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560357}
parent 1f6764dc
......@@ -88,6 +88,35 @@ test("webkit_unit_tests") {
}
}
test("blink_perf_tests") {
deps = [
":blink_perf_tests_sources",
]
}
jumbo_source_set("blink_perf_tests_sources") {
visibility = [] # Allow re-assignment of list.
visibility = [ "*" ]
testonly = true
sources = [
"tests/run_all_tests.cc",
]
deps = [
":controller",
"//base",
"//content/test:test_support",
"//third_party/blink/renderer/core:perf_tests",
]
configs += [
"//third_party/blink/renderer:config",
"//third_party/blink/renderer:inside_blink",
"//third_party/blink/renderer/core:blink_core_pch",
]
}
jumbo_source_set("webkit_unit_tests_sources") {
visibility = [] # Allow re-assignment of list.
visibility = [ "*" ]
......
......@@ -2075,10 +2075,6 @@ jumbo_source_set("unit_tests") {
"svg/svg_path_parser_test.cc",
"svg/svg_text_content_element_test.cc",
"svg/unsafe_svg_attribute_sanitization_test.cc",
"testing/core_unit_test_helper.cc",
"testing/core_unit_test_helper.h",
"testing/page_test_base.cc",
"testing/page_test_base.h",
"testing/sim/sim_canvas.cc",
"testing/sim/sim_canvas.h",
"testing/sim/sim_compositor.cc",
......@@ -2121,6 +2117,7 @@ jumbo_source_set("unit_tests") {
deps = [
":core",
":unit_test_support",
"//mojo/public/cpp/system",
"//testing/gmock",
"//testing/gtest",
......@@ -2135,6 +2132,49 @@ jumbo_source_set("unit_tests") {
}
}
jumbo_source_set("perf_tests") {
testonly = true
sources = [
"layout/visual_rect_mapping_perftest.cc",
]
configs += [
":blink_core_pch",
"//third_party/blink/renderer:config",
"//third_party/blink/renderer:inside_blink",
]
deps = [
":core",
":unit_test_support",
"//mojo/public/cpp/system",
"//testing/gmock",
"//testing/gtest",
]
}
jumbo_source_set("unit_test_support") {
testonly = true
sources = [
"testing/core_unit_test_helper.cc",
"testing/core_unit_test_helper.h",
"testing/page_test_base.cc",
"testing/page_test_base.h",
]
configs += [
":blink_core_pch",
"//third_party/blink/renderer:config",
"//third_party/blink/renderer:inside_blink",
]
deps = [
":core",
"//testing/gmock",
"//testing/gtest",
]
}
# Fuzzer for blink::StyleSheetContents
fuzzer_test("stylesheet_contents_fuzzer") {
sources = [
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_property_tree_printer.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
namespace blink {
class VisualRectPerfTest : public RenderingTest {
public:
void RunPerfTest(unsigned iteration_count,
const LayoutBoxModelObject& target,
const LayoutBoxModelObject& ancestor,
const LayoutRect& rect);
};
void VisualRectPerfTest::RunPerfTest(unsigned iteration_count,
const LayoutBoxModelObject& object,
const LayoutBoxModelObject& ancestor,
const LayoutRect& rect) {
LayoutRect test_rect(rect);
base::TimeTicks start = base::TimeTicks::Now();
for (unsigned count = 0; count < iteration_count; count++) {
object.MapToVisualRectInAncestorSpace(&ancestor, test_rect);
}
LOG(ERROR) << " Time to run MapToVisualRectInAncestorSpace: "
<< (base::TimeTicks::Now() - start).InMilliseconds() << "ms";
start = base::TimeTicks::Now();
size_t total_cache_bytes = 0;
for (unsigned count = 0; count < iteration_count; count++) {
object.MapToVisualRectInAncestorSpace(&ancestor, test_rect,
kUseGeometryMapper);
if (count == 0) {
total_cache_bytes = object.FirstFragment()
.LocalBorderBoxProperties()
.CacheMemoryUsageInBytes();
}
GeometryMapper::ClearCache();
}
LOG(ERROR)
<< " Time to run MapToVisualRectInAncestorSpace w/GeometryMapper: "
<< (base::TimeTicks::Now() - start).InMilliseconds() << "ms";
LOG(ERROR) << " GeometryMapper cache storage size: " << total_cache_bytes
<< " bytes";
}
TEST_F(VisualRectPerfTest, GeometryMapper) {
SetBodyInnerHTML(R"HTML(
<style>
body {
margin:0;
}
.paintLayer {
position: relative;
}
.transform {
transform: translateX(1px);
}
.target {
position: relative;
width: 100px;
height: 100px;
}
</style>
<div id=singleDiv class=target></div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div id=nestedDiv class=target></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class=paintLayer>
<div class=paintLayer>
<div class=paintLayer>
<div class=paintLayer>
<div class=paintLayer>
<div class=paintLayer>
<div class=paintLayer>
<div class=paintLayer
<div class=paintLayer>
<div class=paintLayer>
<div id=nestedPaintLayers class=target></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class=transform>
<div class=transform>
<div class=transform>
<div class=transform>
<div class=transform>
<div class=transform>
<div class=transform>
<div class=transform
<div class=transform>
<div class=transform>
<div id=nestedTransform class=target></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)HTML");
LayoutView* view = GetDocument().View()->GetLayoutView();
LayoutRect rect(0, 0, 100, 100);
unsigned kIterationCount = 1000000;
LOG(ERROR) << "Test with single div:";
RunPerfTest(kIterationCount,
*ToLayoutBox(
GetDocument().getElementById("singleDiv")->GetLayoutObject()),
*view, rect);
LOG(ERROR) << "Test with nested div:";
RunPerfTest(kIterationCount,
*ToLayoutBox(
GetDocument().getElementById("nestedDiv")->GetLayoutObject()),
*view, rect);
LOG(ERROR) << "Test with div nested under PaintLayers:";
RunPerfTest(
kIterationCount,
*ToLayoutBox(
GetDocument().getElementById("nestedPaintLayers")->GetLayoutObject()),
*view, rect);
LOG(ERROR) << "Test with div nested under transforms:";
RunPerfTest(
kIterationCount,
*ToLayoutBox(
GetDocument().getElementById("nestedTransform")->GetLayoutObject()),
*view, rect);
}
} // namespace blink
......@@ -39,4 +39,13 @@ std::unique_ptr<JSONObject> ClipPaintPropertyNode::ToJSON() const {
return json;
}
size_t ClipPaintPropertyNode::CacheMemoryUsageInBytes() const {
size_t total_bytes = sizeof(*this);
if (geometry_mapper_clip_cache_)
total_bytes += sizeof(*geometry_mapper_clip_cache_);
if (Parent())
total_bytes += Parent()->CacheMemoryUsageInBytes();
return total_bytes;
}
} // namespace blink
......@@ -111,6 +111,9 @@ class PLATFORM_EXPORT ClipPaintPropertyNode
std::unique_ptr<JSONObject> ToJSON() const;
// Returns memory usage of the clip cache of this node plus ancestors.
size_t CacheMemoryUsageInBytes() const;
private:
ClipPaintPropertyNode(scoped_refptr<const ClipPaintPropertyNode> parent,
State&& state)
......
......@@ -134,6 +134,9 @@ class PLATFORM_EXPORT EffectPaintPropertyNode
std::unique_ptr<JSONObject> ToJSON() const;
// Returns memory usage of this node plus ancestors.
size_t TreeMemoryUsageInBytes() const;
private:
EffectPaintPropertyNode(scoped_refptr<const EffectPaintPropertyNode> parent,
State&& state)
......
......@@ -54,4 +54,9 @@ String PropertyTreeState::ToTreeString() const {
#endif
size_t PropertyTreeState::CacheMemoryUsageInBytes() const {
return Clip()->CacheMemoryUsageInBytes() +
Transform()->CacheMemoryUsageInBytes();
}
} // namespace blink
......@@ -58,6 +58,10 @@ class PLATFORM_EXPORT PropertyTreeState {
String ToTreeString() const;
#endif
// Returns memory usage of the transform & clip caches of this state plus
// ancestors.
size_t CacheMemoryUsageInBytes() const;
private:
const TransformPaintPropertyNode* transform_;
const ClipPaintPropertyNode* clip_;
......
......@@ -65,4 +65,13 @@ std::unique_ptr<JSONObject> TransformPaintPropertyNode::ToJSON() const {
return json;
}
size_t TransformPaintPropertyNode::CacheMemoryUsageInBytes() const {
size_t total_bytes = sizeof(*this);
if (transform_cache_)
total_bytes += sizeof(*transform_cache_);
if (Parent())
total_bytes += Parent()->CacheMemoryUsageInBytes();
return total_bytes;
}
} // namespace blink
......@@ -143,6 +143,9 @@ class PLATFORM_EXPORT TransformPaintPropertyNode
std::unique_ptr<JSONObject> ToJSON() const;
// Returns memory usage of the transform cache of this node plus ancestors.
size_t CacheMemoryUsageInBytes() const;
private:
TransformPaintPropertyNode(
scoped_refptr<const TransformPaintPropertyNode> parent,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment