Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ group("flutter") {
"//flutter/display_list:display_list_builder_benchmarks",
"//flutter/display_list:display_list_region_benchmarks",
"//flutter/fml:fml_benchmarks",
"//flutter/impeller/aiks:canvas_benchmarks",
"//flutter/impeller/geometry:geometry_benchmarks",
"//flutter/lib/ui:ui_benchmarks",
"//flutter/shell/common:shell_benchmarks",
Expand Down
1 change: 1 addition & 0 deletions ci/builders/linux_host_engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"flutter/display_list:display_list_builder_benchmarks",
"flutter/fml:fml_benchmarks",
"flutter/impeller/geometry:geometry_benchmarks",
"flutter/impeller/aiks:canvas_benchmarks",
"flutter/lib/ui:ui_benchmarks",
"flutter/shell/common:shell_benchmarks",
"flutter/shell/testing",
Expand Down
1 change: 1 addition & 0 deletions ci/builders/standalone/linux_benchmarks.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"flutter/display_list:display_list_builder_benchmarks",
"flutter/fml:fml_benchmarks",
"flutter/impeller/geometry:geometry_benchmarks",
"flutter/impeller/aiks:canvas_benchmarks",
"flutter/lib/ui:ui_benchmarks",
"flutter/shell/common:shell_benchmarks",
"flutter/shell/testing",
Expand Down
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -4857,6 +4857,7 @@ ORIGIN: ../../../flutter/impeller/aiks/aiks_playground_inspector.cc + ../../../f
ORIGIN: ../../../flutter/impeller/aiks/aiks_playground_inspector.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/aiks/canvas.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/aiks/canvas.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/aiks/canvas_benchmarks.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/aiks/canvas_recorder.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/aiks/canvas_type.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/aiks/color_filter.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -7648,6 +7649,7 @@ FILE: ../../../flutter/impeller/aiks/aiks_playground_inspector.cc
FILE: ../../../flutter/impeller/aiks/aiks_playground_inspector.h
FILE: ../../../flutter/impeller/aiks/canvas.cc
FILE: ../../../flutter/impeller/aiks/canvas.h
FILE: ../../../flutter/impeller/aiks/canvas_benchmarks.cc
FILE: ../../../flutter/impeller/aiks/canvas_recorder.h
FILE: ../../../flutter/impeller/aiks/canvas_type.h
FILE: ../../../flutter/impeller/aiks/color_filter.cc
Expand Down
9 changes: 9 additions & 0 deletions impeller/aiks/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,12 @@ impeller_component("aiks_unittests_golden") {
"//flutter/testing:testing_lib",
]
}

executable("canvas_benchmarks") {
testonly = true
sources = [ "canvas_benchmarks.cc" ]
deps = [
":aiks",
"//flutter/benchmarking",
]
}
63 changes: 63 additions & 0 deletions impeller/aiks/canvas_benchmarks.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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 "impeller/aiks/canvas.h"

namespace impeller {

namespace {

using CanvasCallback = size_t (*)(Canvas&);

size_t DrawRect(Canvas& canvas) {
for (auto i = 0; i < 500; i++) {
canvas.DrawRect(Rect::MakeLTRB(0, 0, 100, 100),
{.color = Color::DarkKhaki()});
}
return 500;
}

size_t DrawCircle(Canvas& canvas) {
for (auto i = 0; i < 500; i++) {
canvas.DrawCircle({100, 100}, 5, {.color = Color::DarkKhaki()});
}
return 500;
}

size_t DrawLine(Canvas& canvas) {
for (auto i = 0; i < 500; i++) {
canvas.DrawLine({0, 0}, {100, 100}, {.color = Color::DarkKhaki()});
}
return 500;
}
} // namespace

// A set of benchmarks that measures the CPU cost of encoding canvas operations.
// These benchmarks do not measure the cost of conversion through the HAL, no
// do they measure the GPU side cost of executing the required shader programs.
template <class... Args>
static void BM_CanvasRecord(benchmark::State& state, Args&&... args) {
auto args_tuple = std::make_tuple(std::move(args)...);
auto test_proc = std::get<CanvasCallback>(args_tuple);

size_t op_count = 0u;
size_t canvas_count = 0u;
while (state.KeepRunning()) {
// A new canvas is allocated for each iteration to avoid the benchmark
// becoming a measurement of only the entity vector re-allocation time.
Canvas canvas;
op_count += test_proc(canvas);
canvas_count++;
}
state.counters["TotalOpCount"] = op_count;
state.counters["TotalCanvasCount"] = canvas_count;
}

BENCHMARK_CAPTURE(BM_CanvasRecord, draw_rect, &DrawRect);
BENCHMARK_CAPTURE(BM_CanvasRecord, draw_circle, &DrawCircle);
BENCHMARK_CAPTURE(BM_CanvasRecord, draw_line, &DrawLine);

} // namespace impeller
1 change: 1 addition & 0 deletions testing/benchmark/generate_metrics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ $ENGINE_PATH/src/out/host_release/shell_benchmarks --benchmark_format=json > $EN
$ENGINE_PATH/src/out/host_release/ui_benchmarks --benchmark_format=json > $ENGINE_PATH/src/out/host_release/ui_benchmarks.json
$ENGINE_PATH/src/out/host_release/display_list_builder_benchmarks --benchmark_format=json > $ENGINE_PATH/src/out/host_release/display_list_builder_benchmarks.json
$ENGINE_PATH/src/out/host_release/geometry_benchmarks --benchmark_format=json > $ENGINE_PATH/src/out/host_release/geometry_benchmarks.json
$ENGINE_PATH/src/out/host_release/canvas_benchmarks --benchmark_format=json > $ENGINE_PATH/src/out/host_release/canvas_benchmarks.json
2 changes: 2 additions & 0 deletions testing/benchmark/upload_metrics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ cd "$SCRIPT_DIR"
--json $ENGINE_PATH/src/out/host_release/display_list_builder_benchmarks.json "$@"
"$DART" --disable-dart-dev bin/parse_and_send.dart \
--json $ENGINE_PATH/src/out/host_release/geometry_benchmarks.json "$@"
"$DART" --disable-dart-dev bin/parse_and_send.dart \
--json $ENGINE_PATH/src/out/host_release/canvas_benchmarks.json "$@"
4 changes: 4 additions & 0 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ def run_engine_benchmarks(build_dir, executable_filter):
build_dir, 'geometry_benchmarks', executable_filter, icu_flags
)

run_engine_executable(
build_dir, 'canvas_benchmarks', executable_filter, icu_flags
)

if is_linux():
run_engine_executable(
build_dir, 'txt_benchmarks', executable_filter, icu_flags
Expand Down