Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7b9f59e

Browse files
authored
Run benchmarks on try jobs. (#9493)
Fixes flutter/flutter#35089. These runs only ensure that the benchmark harnesses are valid. No information should be collected on the trybots because the environments are not consistent and the builds are not optimized.
1 parent 185087a commit 7b9f59e

4 files changed

Lines changed: 59 additions & 6 deletions

File tree

shell/common/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ shell_host_executable("shell_benchmarks") {
173173
]
174174

175175
deps = [
176+
":shell_unittests_fixtures",
176177
"$flutter_root/benchmarking",
178+
"$flutter_root/testing:testing_lib",
177179
]
178180
}

shell/common/shell_benchmarks.cc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44

55
#include "flutter/benchmarking/benchmarking.h"
66
#include "flutter/fml/logging.h"
7+
#include "flutter/runtime/dart_vm.h"
78
#include "flutter/shell/common/shell.h"
89
#include "flutter/shell/common/thread_host.h"
10+
#include "flutter/testing/testing.h"
911

1012
namespace flutter {
1113

1214
static void StartupAndShutdownShell(benchmark::State& state,
1315
bool measure_startup,
1416
bool measure_shutdown) {
17+
auto assets_dir = fml::OpenDirectory(testing::GetFixturesPath(), false,
18+
fml::FilePermission::kRead);
1519
std::unique_ptr<Shell> shell;
1620
std::unique_ptr<ThreadHost> thread_host;
1721
{
@@ -20,7 +24,35 @@ static void StartupAndShutdownShell(benchmark::State& state,
2024
settings.task_observer_add = [](intptr_t, fml::closure) {};
2125
settings.task_observer_remove = [](intptr_t) {};
2226

23-
// Measure the time it takes to setup the threads as well.
27+
if (DartVM::IsRunningPrecompiledCode()) {
28+
settings.vm_snapshot_data = [&]() {
29+
return fml::FileMapping::CreateReadOnly(assets_dir, "vm_snapshot_data");
30+
};
31+
32+
settings.isolate_snapshot_data = [&]() {
33+
return fml::FileMapping::CreateReadOnly(assets_dir,
34+
"isolate_snapshot_data");
35+
};
36+
37+
settings.vm_snapshot_instr = [&]() {
38+
return fml::FileMapping::CreateReadExecute(assets_dir,
39+
"vm_snapshot_instr");
40+
};
41+
42+
settings.isolate_snapshot_instr = [&]() {
43+
return fml::FileMapping::CreateReadExecute(assets_dir,
44+
"isolate_snapshot_instr");
45+
};
46+
47+
} else {
48+
settings.application_kernels = [&]() {
49+
std::vector<std::unique_ptr<const fml::Mapping>> kernel_mappings;
50+
kernel_mappings.emplace_back(
51+
fml::FileMapping::CreateReadOnly(assets_dir, "kernel_blob.bin"));
52+
return kernel_mappings;
53+
};
54+
}
55+
2456
thread_host = std::make_unique<ThreadHost>(
2557
"io.flutter.bench.", ThreadHost::Type::Platform |
2658
ThreadHost::Type::GPU | ThreadHost::Type::IO |

testing/BUILD.gn

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,35 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
source_set("testing") {
5+
source_set("testing_lib") {
66
testonly = true
77

88
sources = [
9-
"$flutter_root/testing/run_all_unittests.cc",
109
"$flutter_root/testing/testing.cc",
1110
"$flutter_root/testing/testing.h",
12-
"$flutter_root/testing/thread_test.cc",
13-
"$flutter_root/testing/thread_test.h",
1411
]
1512

1613
public_deps = [
1714
"$flutter_root/fml",
1815
"//third_party/googletest:gtest",
1916
]
20-
2117
public_configs = [ "$flutter_root:config" ]
2218
}
2319

20+
source_set("testing") {
21+
testonly = true
22+
23+
sources = [
24+
"$flutter_root/testing/run_all_unittests.cc",
25+
"$flutter_root/testing/thread_test.cc",
26+
"$flutter_root/testing/thread_test.h",
27+
]
28+
29+
public_deps = [
30+
":testing_lib",
31+
]
32+
}
33+
2434
source_set("dart") {
2535
testonly = true
2636

testing/run_tests.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ echo "Running flow_unittests..."
3232
echo "Running fml_unittests..."
3333
"$HOST_DIR/fml_unittests" --gtest_filter="-*TimeSensitiveTest*"
3434

35+
echo "Running fml_benchmarks..."
36+
"$HOST_DIR/fml_benchmarks"
37+
3538
echo "Running runtime_unittests..."
3639
"$HOST_DIR/runtime_unittests"
3740

3841
echo "Running shell_unittests..."
3942
"$HOST_DIR/shell_unittests"
4043

44+
echo "Running shell_benchmarks..."
45+
"$HOST_DIR/shell_benchmarks"
46+
4147
echo "Running client_wrapper_unittests..."
4248
"$HOST_DIR/client_wrapper_unittests"
4349

@@ -47,6 +53,9 @@ echo "Running client_wrapper_glfw_unittests..."
4753
echo "Running txt_unittests..."
4854
"$HOST_DIR/txt_unittests" --font-directory="$BUILDROOT_DIR/flutter/third_party/txt/third_party/fonts"
4955

56+
echo "Running txt_benchmarks..."
57+
"$HOST_DIR/txt_benchmarks" --font-directory="$BUILDROOT_DIR/flutter/third_party/txt/third_party/fonts"
58+
5059
# Build flutter/sky/packages.
5160
#
5261
# flutter/testing/dart/pubspec.yaml contains harcoded path deps to

0 commit comments

Comments
 (0)