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

Reland "[DisplayList] Allow random access to ops through indexing" #54676

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions display_list/benchmarking/dl_builder_benchmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,60 @@ static void BM_DisplayListDispatchDefault(
}
}

static void BM_DisplayListDispatchByIndexDefault(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
DlIndex end = display_list->GetRecordCount();
for (DlIndex i = 0u; i < end; i++) {
display_list->Dispatch(receiver, i);
}
}
}

static void BM_DisplayListDispatchByIteratorDefault(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
for (DlIndex i : *display_list) {
display_list->Dispatch(receiver, i);
}
}
}

static void BM_DisplayListDispatchByVectorDefault(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
std::vector<DlIndex> indices =
display_list->GetCulledIndices(display_list->bounds());
for (DlIndex index : indices) {
display_list->Dispatch(receiver, index);
}
}
}

static void BM_DisplayListDispatchCull(benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
Expand All @@ -236,6 +290,26 @@ static void BM_DisplayListDispatchCull(benchmark::State& state,
}
}

static void BM_DisplayListDispatchByVectorCull(
benchmark::State& state,
DisplayListDispatchBenchmarkType type) {
bool prepare_rtree = NeedPrepareRTree(type);
DisplayListBuilder builder(prepare_rtree);
for (int i = 0; i < 5; i++) {
InvokeAllOps(builder);
}
auto display_list = builder.Build();
SkRect rect = SkRect::MakeLTRB(0, 0, 100, 100);
EXPECT_FALSE(rect.contains(display_list->bounds()));
DlOpReceiverIgnore receiver;
while (state.KeepRunning()) {
std::vector<DlIndex> indices = display_list->GetCulledIndices(rect);
for (DlIndex index : indices) {
display_list->Dispatch(receiver, index);
}
}
}

BENCHMARK_CAPTURE(BM_DisplayListBuilderDefault,
kDefault,
DisplayListBuilderBenchmarkType::kDefault)
Expand Down Expand Up @@ -370,4 +444,24 @@ BENCHMARK_CAPTURE(BM_DisplayListDispatchCull,
DisplayListDispatchBenchmarkType::kCulledWithRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByIndexDefault,
kDefaultNoRtree,
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByIteratorDefault,
kDefaultNoRtree,
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByVectorDefault,
kDefaultNoRtree,
DisplayListDispatchBenchmarkType::kDefaultNoRtree)
->Unit(benchmark::kMicrosecond);

BENCHMARK_CAPTURE(BM_DisplayListDispatchByVectorCull,
kCulledWithRtree,
DisplayListDispatchBenchmarkType::kCulledWithRtree)
->Unit(benchmark::kMicrosecond);

} // namespace flutter
Loading