This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Create benchmarks for DisplayListBuilder #34910
Merged
auto-submit
merged 7 commits into
flutter:main
from
ColdPaleLight:display_list_benchmarks
Jul 29, 2022
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8831949
Create benchmarks for DisplayListBuilder
ColdPaleLight c25ee8b
Update run_test.py
ColdPaleLight fde075e
format
ColdPaleLight a1b7e6e
Tweak benchmarks
ColdPaleLight efb5302
clean code
ColdPaleLight 1948610
Merge branch 'flutter:main' into display_list_benchmarks
ColdPaleLight 08c0aa0
Tweak code
ColdPaleLight File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| // Copyright 2013 The Flutter 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 "flutter/benchmarking/benchmarking.h" | ||
| #include "flutter/display_list/display_list_test_utils.h" | ||
|
|
||
| namespace flutter { | ||
| namespace { | ||
|
|
||
| static const int kDefault = 0; | ||
| static const int kBounds = 1; | ||
| static const int kBoundsAndRtree = 2; | ||
flar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| static void InvokeAllRenderingOps(DisplayListBuilder& builder) { | ||
| for (auto& group : testing::allRenderingOps) { | ||
flar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (size_t i = 0; i < group.variants.size(); i++) { | ||
| auto& invocation = group.variants[i]; | ||
| invocation.Invoke(builder); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| static void Complete(DisplayListBuilder& builder, int type) { | ||
| auto display_list = builder.Build(); | ||
| switch (type) { | ||
| case kBounds: | ||
| display_list->bounds(); | ||
| break; | ||
| case kBoundsAndRtree: | ||
| display_list->bounds(); | ||
| display_list->rtree(); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| static void BM_DisplayListBuiderDefault(benchmark::State& state) { | ||
| int type = state.range(0); | ||
| while (state.KeepRunning()) { | ||
| DisplayListBuilder builder; | ||
| InvokeAllRenderingOps(builder); | ||
| Complete(builder, type); | ||
| } | ||
| } | ||
|
|
||
| static void BM_DisplayListBuiderWithScaleAndTranslate(benchmark::State& state) { | ||
| int type = state.range(0); | ||
| while (state.KeepRunning()) { | ||
| DisplayListBuilder builder; | ||
| builder.scale(3.5, 3.5); | ||
| builder.translate(10.3, 6.9); | ||
| InvokeAllRenderingOps(builder); | ||
| Complete(builder, type); | ||
| } | ||
| } | ||
|
|
||
| static void BM_DisplayListBuiderWithPerspective(benchmark::State& state) { | ||
| int type = state.range(0); | ||
| while (state.KeepRunning()) { | ||
| DisplayListBuilder builder; | ||
| builder.transformFullPerspective(0, 1, 0, 12, 1, 0, 0, 33, 3, 2, 5, 29, 0, | ||
| 0, 0, 12); | ||
| InvokeAllRenderingOps(builder); | ||
| Complete(builder, type); | ||
| } | ||
| } | ||
|
|
||
| static void BM_DisplayListBuiderWithClipRect(benchmark::State& state) { | ||
| int type = state.range(0); | ||
| while (state.KeepRunning()) { | ||
| DisplayListBuilder builder; | ||
| SkRect clip_bounds = SkRect::MakeLTRB(6.5, 7.3, 90.2, 85.7); | ||
flar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| builder.clipRect(clip_bounds, SkClipOp::kIntersect, true); | ||
| InvokeAllRenderingOps(builder); | ||
| Complete(builder, type); | ||
| } | ||
| } | ||
|
|
||
| static void BM_DisplayListBuiderWithSaveLayer(benchmark::State& state) { | ||
| int type = state.range(0); | ||
| while (state.KeepRunning()) { | ||
| DisplayListBuilder builder; | ||
| for (auto& group : testing::allRenderingOps) { | ||
| for (size_t i = 0; i < group.variants.size(); i++) { | ||
| auto& invocation = group.variants[i]; | ||
| builder.saveLayer(nullptr, false); | ||
| invocation.Invoke(builder); | ||
| builder.restore(); | ||
| } | ||
| } | ||
| Complete(builder, type); | ||
| } | ||
| } | ||
|
|
||
| static void BM_DisplayListBuiderWithSaveLayerAndImageFilter( | ||
| benchmark::State& state) { | ||
| int type = state.range(0); | ||
| while (state.KeepRunning()) { | ||
| DisplayListBuilder builder; | ||
| for (auto& group : testing::allRenderingOps) { | ||
| for (size_t i = 0; i < group.variants.size(); i++) { | ||
| auto& invocation = group.variants[i]; | ||
| builder.saveLayer(nullptr, SaveLayerOptions::kNoAttributes, | ||
flar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| &testing::kTestBlurImageFilter1); | ||
| invocation.Invoke(builder); | ||
| builder.restore(); | ||
| } | ||
| } | ||
| Complete(builder, type); | ||
| } | ||
| } | ||
|
|
||
| BENCHMARK(BM_DisplayListBuiderDefault) | ||
| ->Args({kDefault}) | ||
flar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ->Args({kBounds}) | ||
| ->Args({kBoundsAndRtree}) | ||
| ->Unit(benchmark::kMillisecond); | ||
|
|
||
| BENCHMARK(BM_DisplayListBuiderWithScaleAndTranslate) | ||
| ->Args({kDefault}) | ||
| ->Args({kBounds}) | ||
| ->Args({kBoundsAndRtree}) | ||
| ->Unit(benchmark::kMillisecond); | ||
|
|
||
| BENCHMARK(BM_DisplayListBuiderWithPerspective) | ||
| ->Args({kDefault}) | ||
| ->Args({kBounds}) | ||
| ->Args({kBoundsAndRtree}) | ||
| ->Unit(benchmark::kMillisecond); | ||
|
|
||
| BENCHMARK(BM_DisplayListBuiderWithClipRect) | ||
| ->Args({kDefault}) | ||
| ->Args({kBounds}) | ||
| ->Args({kBoundsAndRtree}) | ||
| ->Unit(benchmark::kMillisecond); | ||
|
|
||
| BENCHMARK(BM_DisplayListBuiderWithSaveLayer) | ||
| ->Args({kDefault}) | ||
| ->Args({kBounds}) | ||
| ->Args({kBoundsAndRtree}) | ||
| ->Unit(benchmark::kMillisecond); | ||
|
|
||
| BENCHMARK(BM_DisplayListBuiderWithSaveLayerAndImageFilter) | ||
| ->Args({kDefault}) | ||
| ->Args({kBounds}) | ||
| ->Args({kBoundsAndRtree}) | ||
| ->Unit(benchmark::kMillisecond); | ||
|
|
||
| } // namespace flutter | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.