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
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_
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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) {
Comment on lines +203 to +205
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little weird where if we are on iOS but don't have shell_enable_metal we get an empty source set. Seems like the conditional should be higher at the usage of the source set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was just moved from inside the overall enable_unittests block into its own block that also allows for iOS, so it was already like that (except for the iOS condition).

I am a little wary of poking this because the large comment directly above the source_set suggests that there's some stuff going on here that's not entirely straightforward.

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