Skip to content

Commit

Permalink
Create a DisplayList benchmarks dylib on iOS that can be linked to fr…
Browse files Browse the repository at this point in the history
…om a test app. To run the benchmarks,

call the exported entrypoint RunBenchmarks(argc, argv).
  • Loading branch information
George Wright committed Jan 13, 2022
1 parent 9ce6838 commit 3ae4d8d
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 30 deletions.
23 changes: 23 additions & 0 deletions benchmarking/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
16 changes: 16 additions & 0 deletions benchmarking/library.cc
Original file line number Diff line number Diff line change
@@ -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;
}
}
12 changes: 12 additions & 0 deletions benchmarking/library.h
Original file line number Diff line number Diff line change
@@ -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_
39 changes: 39 additions & 0 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
}
2 changes: 1 addition & 1 deletion display_list/display_list_benchmarks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
64 changes: 35 additions & 29 deletions testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
}
Expand All @@ -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
}
}

0 comments on commit 3ae4d8d

Please sign in to comment.