Create a DisplayList benchmarks dylib on iOS (flutter/engine#30833)

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).
This commit is contained in:
George Wright
2022-01-13 14:32:54 -08:00
committed by GitHub
parent d160719f16
commit 6b45335bf1
7 changed files with 128 additions and 30 deletions

View File

@@ -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",
]
}

View File

@@ -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;
}
}

View File

@@ -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_

View File

@@ -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

View File

@@ -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",
]
}
}

View File

@@ -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"

View File

@@ -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
}
}