Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 31bbe61

Browse files
authored
add new builder benchmark with a global saveLayer (#51236)
The existing DisplayListBuilder benchmarks that have a SaveLayer call do so around each rendering call which stresses measuring the cost of the SaveLayer/Restore calls. This new benchmark does a single SaveLayer/Restore around the entire array of rendering ops to measure the performance of adding new calls inside an existing layer. No tests because this is just a new benchmark.
1 parent 43e81fc commit 31bbe61

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

display_list/benchmarking/dl_builder_benchmarks.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,28 @@ static void BM_DisplayListBuilderWithClipRect(
108108
}
109109
}
110110

111+
static void BM_DisplayListBuilderWithGlobalSaveLayer(
112+
benchmark::State& state,
113+
DisplayListBuilderBenchmarkType type) {
114+
bool prepare_rtree = NeedPrepareRTree(type);
115+
while (state.KeepRunning()) {
116+
DisplayListBuilder builder(prepare_rtree);
117+
builder.Scale(3.5, 3.5);
118+
builder.Translate(10.3, 6.9);
119+
builder.SaveLayer(nullptr, nullptr);
120+
builder.Translate(45.3, 27.9);
121+
DlOpReceiver& receiver = DisplayListBuilderBenchmarkAccessor(builder);
122+
for (auto& group : allRenderingOps) {
123+
for (size_t i = 0; i < group.variants.size(); i++) {
124+
auto& invocation = group.variants[i];
125+
invocation.Invoke(receiver);
126+
}
127+
}
128+
builder.Restore();
129+
Complete(builder, type);
130+
}
131+
}
132+
111133
static void BM_DisplayListBuilderWithSaveLayer(
112134
benchmark::State& state,
113135
DisplayListBuilderBenchmarkType type) {
@@ -217,6 +239,23 @@ BENCHMARK_CAPTURE(BM_DisplayListBuilderWithClipRect,
217239
DisplayListBuilderBenchmarkType::kBoundsAndRtree)
218240
->Unit(benchmark::kMicrosecond);
219241

242+
BENCHMARK_CAPTURE(BM_DisplayListBuilderWithGlobalSaveLayer,
243+
kDefault,
244+
DisplayListBuilderBenchmarkType::kDefault)
245+
->Unit(benchmark::kMicrosecond);
246+
BENCHMARK_CAPTURE(BM_DisplayListBuilderWithGlobalSaveLayer,
247+
kBounds,
248+
DisplayListBuilderBenchmarkType::kBounds)
249+
->Unit(benchmark::kMicrosecond);
250+
BENCHMARK_CAPTURE(BM_DisplayListBuilderWithGlobalSaveLayer,
251+
kRtree,
252+
DisplayListBuilderBenchmarkType::kRtree)
253+
->Unit(benchmark::kMicrosecond);
254+
BENCHMARK_CAPTURE(BM_DisplayListBuilderWithGlobalSaveLayer,
255+
kBoundsAndRtree,
256+
DisplayListBuilderBenchmarkType::kBoundsAndRtree)
257+
->Unit(benchmark::kMicrosecond);
258+
220259
BENCHMARK_CAPTURE(BM_DisplayListBuilderWithSaveLayer,
221260
kDefault,
222261
DisplayListBuilderBenchmarkType::kDefault)

0 commit comments

Comments
 (0)