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

Commit b65b742

Browse files
committed
[DisplayList] Allow random access to ops through indexing
1 parent 5d8ee52 commit b65b742

File tree

8 files changed

+1207
-461
lines changed

8 files changed

+1207
-461
lines changed

display_list/benchmarking/dl_builder_benchmarks.cc

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,60 @@ static void BM_DisplayListDispatchDefault(
220220
}
221221
}
222222

223+
static void BM_DisplayListDispatchByIndexDefault(
224+
benchmark::State& state,
225+
DisplayListDispatchBenchmarkType type) {
226+
bool prepare_rtree = NeedPrepareRTree(type);
227+
DisplayListBuilder builder(prepare_rtree);
228+
for (int i = 0; i < 5; i++) {
229+
InvokeAllOps(builder);
230+
}
231+
auto display_list = builder.Build();
232+
DlOpReceiverIgnore receiver;
233+
while (state.KeepRunning()) {
234+
DlIndex end = display_list->GetRecordCount();
235+
for (DlIndex i = 0u; i < end; i++) {
236+
display_list->Dispatch(receiver, i);
237+
}
238+
}
239+
}
240+
241+
static void BM_DisplayListDispatchByIteratorDefault(
242+
benchmark::State& state,
243+
DisplayListDispatchBenchmarkType type) {
244+
bool prepare_rtree = NeedPrepareRTree(type);
245+
DisplayListBuilder builder(prepare_rtree);
246+
for (int i = 0; i < 5; i++) {
247+
InvokeAllOps(builder);
248+
}
249+
auto display_list = builder.Build();
250+
DlOpReceiverIgnore receiver;
251+
while (state.KeepRunning()) {
252+
for (DlIndex i : *display_list) {
253+
display_list->Dispatch(receiver, i);
254+
}
255+
}
256+
}
257+
258+
static void BM_DisplayListDispatchByVectorDefault(
259+
benchmark::State& state,
260+
DisplayListDispatchBenchmarkType type) {
261+
bool prepare_rtree = NeedPrepareRTree(type);
262+
DisplayListBuilder builder(prepare_rtree);
263+
for (int i = 0; i < 5; i++) {
264+
InvokeAllOps(builder);
265+
}
266+
auto display_list = builder.Build();
267+
DlOpReceiverIgnore receiver;
268+
while (state.KeepRunning()) {
269+
std::vector<DlIndex> indices =
270+
display_list->GetCulledIndices(display_list->bounds());
271+
for (DlIndex index : indices) {
272+
display_list->Dispatch(receiver, index);
273+
}
274+
}
275+
}
276+
223277
static void BM_DisplayListDispatchCull(benchmark::State& state,
224278
DisplayListDispatchBenchmarkType type) {
225279
bool prepare_rtree = NeedPrepareRTree(type);
@@ -236,6 +290,26 @@ static void BM_DisplayListDispatchCull(benchmark::State& state,
236290
}
237291
}
238292

293+
static void BM_DisplayListDispatchByVectorCull(
294+
benchmark::State& state,
295+
DisplayListDispatchBenchmarkType type) {
296+
bool prepare_rtree = NeedPrepareRTree(type);
297+
DisplayListBuilder builder(prepare_rtree);
298+
for (int i = 0; i < 5; i++) {
299+
InvokeAllOps(builder);
300+
}
301+
auto display_list = builder.Build();
302+
SkRect rect = SkRect::MakeLTRB(0, 0, 100, 100);
303+
EXPECT_FALSE(rect.contains(display_list->bounds()));
304+
DlOpReceiverIgnore receiver;
305+
while (state.KeepRunning()) {
306+
std::vector<DlIndex> indices = display_list->GetCulledIndices(rect);
307+
for (DlIndex index : indices) {
308+
display_list->Dispatch(receiver, index);
309+
}
310+
}
311+
}
312+
239313
BENCHMARK_CAPTURE(BM_DisplayListBuilderDefault,
240314
kDefault,
241315
DisplayListBuilderBenchmarkType::kDefault)
@@ -370,4 +444,24 @@ BENCHMARK_CAPTURE(BM_DisplayListDispatchCull,
370444
DisplayListDispatchBenchmarkType::kCulledWithRtree)
371445
->Unit(benchmark::kMicrosecond);
372446

447+
BENCHMARK_CAPTURE(BM_DisplayListDispatchByIndexDefault,
448+
kDefaultNoRtree,
449+
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
450+
->Unit(benchmark::kMicrosecond);
451+
452+
BENCHMARK_CAPTURE(BM_DisplayListDispatchByIteratorDefault,
453+
kDefaultNoRtree,
454+
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
455+
->Unit(benchmark::kMicrosecond);
456+
457+
BENCHMARK_CAPTURE(BM_DisplayListDispatchByVectorDefault,
458+
kDefaultNoRtree,
459+
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
460+
->Unit(benchmark::kMicrosecond);
461+
462+
BENCHMARK_CAPTURE(BM_DisplayListDispatchByVectorCull,
463+
kCulledWithRtree,
464+
DisplayListDispatchBenchmarkType::kCulledWithRtree)
465+
->Unit(benchmark::kMicrosecond);
466+
373467
} // namespace flutter

0 commit comments

Comments
 (0)