From 3ae4d8db4e45e456ab9e20b02eede055ff048702 Mon Sep 17 00:00:00 2001 From: George Wright Date: Wed, 12 Jan 2022 16:54:41 -0800 Subject: [PATCH 1/2] Create a DisplayList benchmarks dylib on iOS that can be linked to from a test app. To run the benchmarks, call the exported entrypoint RunBenchmarks(argc, argv). --- benchmarking/BUILD.gn | 23 +++++++++ benchmarking/library.cc | 16 +++++++ benchmarking/library.h | 12 +++++ display_list/BUILD.gn | 39 ++++++++++++++++ display_list/display_list_benchmarks.h | 2 +- testing/BUILD.gn | 64 ++++++++++++++------------ 6 files changed, 126 insertions(+), 30 deletions(-) create mode 100644 benchmarking/library.cc create mode 100644 benchmarking/library.h diff --git a/benchmarking/BUILD.gn b/benchmarking/BUILD.gn index 8cdaf471ec958..08a33710fe06f 100644 --- a/benchmarking/BUILD.gn +++ b/benchmarking/BUILD.gn @@ -24,3 +24,26 @@ source_set("benchmarking") { ":benchmark_config", ] } + +config("benchmark_library_config") { + if (is_ios) { + ldflags = [ "-Wl,-exported_symbol,_RunBenchmarks" ] + } +} + +source_set("benchmarking_library") { + testonly = true + + sources = [ + "library.cc", + "library.h", + ] + + public_deps = [ "//third_party/benchmark" ] + + public_configs = [ + "//flutter:config", + ":benchmark_config", + ":benchmark_library_config", + ] +} diff --git a/benchmarking/library.cc b/benchmarking/library.cc new file mode 100644 index 0000000000000..5dcacce49b800 --- /dev/null +++ b/benchmarking/library.cc @@ -0,0 +1,16 @@ +// 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 "third_party/benchmark/include/benchmark/benchmark.h" + +#include "library.h" + +extern "C" { + +int RunBenchmarks(int argc, char** argv) { + benchmark::Initialize(&argc, argv); + ::benchmark::RunSpecifiedBenchmarks(); + return 0; +} +} diff --git a/benchmarking/library.h b/benchmarking/library.h new file mode 100644 index 0000000000000..e2e41fee73fdd --- /dev/null +++ b/benchmarking/library.h @@ -0,0 +1,12 @@ +// 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. + +#ifndef FLUTTER_BENCHMARKING_LIBRARY_H_ +#define FLUTTER_BENCHMARKING_LIBRARY_H_ + +extern "C" { +__attribute__((visibility("default"))) int RunBenchmarks(int argc, char** argv); +} + +#endif // FLUTTER_BENCHMARKING_LIBRARY_H_ diff --git a/display_list/BUILD.gn b/display_list/BUILD.gn index 13aa1bb3b5c4f..88f957d33ccb4 100644 --- a/display_list/BUILD.gn +++ b/display_list/BUILD.gn @@ -85,3 +85,42 @@ if (enable_unittests) { } } } + +if (is_ios) { + shared_library("ios_display_list_benchmarks") { + testonly = true + visibility = [ ":*" ] + + configs -= [ + "//build/config/gcc:symbol_visibility_hidden", + "//build/config:symbol_visibility_hidden", + ] + configs += [ "//flutter/benchmarking:benchmark_library_config" ] + cflags = [ + "-fobjc-arc", + "-mios-simulator-version-min=$ios_testing_deployment_target", + ] + ldflags = + [ "-Wl,-install_name,@rpath/libios_display_list_benchmarks.dylib" ] + + sources = [ + "display_list_benchmarks.cc", + "display_list_benchmarks.h", + "display_list_benchmarks_metal.cc", + ] + + deps = [ + ":display_list", + ":display_list_benchmarks_fixtures", + "//flutter/benchmarking:benchmarking_library", + "//flutter/common/graphics", + "//flutter/fml", + "//flutter/testing:metal", + "//flutter/testing:skia", + "//flutter/testing:testing_lib", + "//third_party/benchmark", + "//third_party/dart/runtime:libdart_jit", # for tracing + "//third_party/skia", + ] + } +} diff --git a/display_list/display_list_benchmarks.h b/display_list/display_list_benchmarks.h index 8cf6af3a48699..a4efa7961db9d 100644 --- a/display_list/display_list_benchmarks.h +++ b/display_list/display_list_benchmarks.h @@ -5,10 +5,10 @@ #ifndef FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_H_ #define FLUTTER_FLOW_DISPLAY_LIST_BENCHMARKS_H_ -#include "flutter/benchmarking/benchmarking.h" #include "flutter/fml/mapping.h" #include "flutter/testing/testing.h" +#include "third_party/benchmark/include/benchmark/benchmark.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/core/SkSurface.h" diff --git a/testing/BUILD.gn b/testing/BUILD.gn index 31b0edec486ad..9ae50f47e8d00 100644 --- a/testing/BUILD.gn +++ b/testing/BUILD.gn @@ -165,35 +165,6 @@ if (enable_unittests) { } } - # All targets on all platforms should be able to use the Metal utilities. On - # platforms where Metal is not available, the tests must be skipped or - # implemented to use another available client rendering API. This is usually - # either OpenGL which is portably implemented via SwiftShader or the software - # backend. This way, all tests compile on all platforms but the Metal backend - # is exercised on platforms where Metal itself is available. - source_set("metal") { - if (shell_enable_metal) { - sources = [ - "test_metal_context.h", - "test_metal_context.mm", - "test_metal_surface.cc", - "test_metal_surface.h", - "test_metal_surface_impl.h", - "test_metal_surface_impl.mm", - ] - - # Skia's Vulkan support is enabled for all platforms, and so parts of - # Skia's graphics context reference Vulkan symbols. - deps = [ - ":skia", - "//flutter/fml", - "//flutter/vulkan", - ] - } - - testonly = true - } - test_fixtures("testing_fixtures") { fixtures = [] } @@ -220,3 +191,38 @@ if (enable_unittests) { } } } + +# All targets on all platforms should be able to use the Metal utilities. On +# platforms where Metal is not available, the tests must be skipped or +# implemented to use another available client rendering API. This is usually +# either OpenGL which is portably implemented via SwiftShader or the software +# backend. This way, all tests compile on all platforms but the Metal backend +# is exercised on platforms where Metal itself is available. +# +# On iOS, this is enabled to allow for Metal tests to run within a test app +if (enable_unittests || is_ios) { + source_set("metal") { + if (shell_enable_metal) { + sources = [ + "test_metal_context.h", + "test_metal_context.mm", + "test_metal_surface.cc", + "test_metal_surface.h", + "test_metal_surface_impl.h", + "test_metal_surface_impl.mm", + ] + deps = [ + ":skia", + "//flutter/fml", + ] + + # Skia's Vulkan support is enabled for all platforms (except iOS), and so parts of + # Skia's graphics context reference Vulkan symbols. + if (!is_ios) { + deps += [ "//flutter/vulkan" ] + } + } + + testonly = true + } +} From 78991318008cb6396a509ce1002ab921fd1bc9f5 Mon Sep 17 00:00:00 2001 From: George Wright Date: Thu, 13 Jan 2022 10:33:08 -0800 Subject: [PATCH 2/2] licences --- ci/licenses_golden/licenses_flutter | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 3f8f5cf73d641..0ef87816feefb 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -20,6 +20,8 @@ FILE: ../../../flutter/assets/directory_asset_bundle.cc FILE: ../../../flutter/assets/directory_asset_bundle.h FILE: ../../../flutter/benchmarking/benchmarking.cc FILE: ../../../flutter/benchmarking/benchmarking.h +FILE: ../../../flutter/benchmarking/library.cc +FILE: ../../../flutter/benchmarking/library.h FILE: ../../../flutter/common/constants.h FILE: ../../../flutter/common/exported_symbols.sym FILE: ../../../flutter/common/graphics/gl_context_switch.cc