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

Commit 30004c5

Browse files
committed
Revert "Reland "Add benchmarks to measure dart -> native time (#28492)""
This reverts commit 79b92ab.
1 parent 79b92ab commit 30004c5

File tree

10 files changed

+94
-251
lines changed

10 files changed

+94
-251
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ FILE: ../../../flutter/shell/common/canvas_spy.h
691691
FILE: ../../../flutter/shell/common/canvas_spy_unittests.cc
692692
FILE: ../../../flutter/shell/common/context_options.cc
693693
FILE: ../../../flutter/shell/common/context_options.h
694-
FILE: ../../../flutter/shell/common/dart_native_benchmarks.cc
695694
FILE: ../../../flutter/shell/common/display.h
696695
FILE: ../../../flutter/shell/common/display_manager.cc
697696
FILE: ../../../flutter/shell/common/display_manager.h

runtime/dart_isolate_unittests.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,11 @@ TEST_F(DartIsolateTest, CanRunDartCodeCodeSynchronously) {
247247

248248
TEST_F(DartIsolateTest, CanRegisterNativeCallback) {
249249
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
250-
AddNativeCallback(
251-
"NotifyNative",
252-
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) { Signal(); })));
250+
AddNativeCallback("NotifyNative",
251+
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
252+
FML_LOG(ERROR) << "Hello from Dart!";
253+
Signal();
254+
})));
253255
const auto settings = CreateSettingsForFixture();
254256
auto vm_ref = DartVMRef::Create(settings);
255257
auto thread = CreateNewThread();
@@ -522,9 +524,11 @@ TEST_F(DartIsolateTest, DISABLED_ValidLoadingUnitSucceeds) {
522524
}
523525

524526
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
525-
AddNativeCallback(
526-
"NotifyNative",
527-
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) { Signal(); })));
527+
AddNativeCallback("NotifyNative",
528+
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
529+
FML_LOG(ERROR) << "Hello from Dart!";
530+
Signal();
531+
})));
528532
AddNativeCallback(
529533
"NotifySuccess", CREATE_NATIVE_ENTRY([this](Dart_NativeArguments args) {
530534
auto bool_handle = Dart_GetNativeArgument(args, 0);

shell/common/BUILD.gn

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,13 @@ if (enable_unittests) {
158158
}
159159

160160
shell_host_executable("shell_benchmarks") {
161-
sources = [
162-
"dart_native_benchmarks.cc",
163-
"shell_benchmarks.cc",
164-
]
161+
sources = [ "shell_benchmarks.cc" ]
165162

166163
deps = [
167164
":shell_unittests_fixtures",
168165
"//flutter/benchmarking",
169166
"//flutter/flow",
170167
"//flutter/testing:dart",
171-
"//flutter/testing:fixture_test",
172168
"//flutter/testing:testing_lib",
173169
]
174170
}

shell/common/dart_native_benchmarks.cc

Lines changed: 0 additions & 103 deletions
This file was deleted.

shell/common/fixtures/shell_test.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ void sayHiFromFixturesAreFunctionalMain() native 'SayHiFromFixturesAreFunctional
7575

7676
void notifyNative() native 'NotifyNative';
7777

78-
@pragma('vm:entry-point')
79-
void thousandCallsToNative() {
80-
for (int i = 0; i < 1000; i++) {
81-
notifyNative();
82-
}
83-
}
84-
8578
void secondaryIsolateMain(String message) {
8679
print('Secondary isolate got message: ' + message);
8780
notifyNative();

testing/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ source_set("fixture_test") {
9090
testonly = true
9191

9292
sources = [
93-
"dart_fixture.cc",
94-
"dart_fixture.h",
9593
"fixture_test.cc",
9694
"fixture_test.h",
9795
]

testing/dart_fixture.cc

Lines changed: 0 additions & 72 deletions
This file was deleted.

testing/dart_fixture.h

Lines changed: 0 additions & 49 deletions
This file was deleted.

testing/fixture_test.cc

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,71 @@
44

55
#include "flutter/testing/fixture_test.h"
66

7-
#include "flutter/testing/dart_fixture.h"
8-
97
namespace flutter {
108
namespace testing {
119

12-
FixtureTest::FixtureTest() : DartFixture() {}
10+
FixtureTest::FixtureTest()
11+
: FixtureTest("kernel_blob.bin",
12+
kDefaultAOTAppELFFileName,
13+
kDefaultAOTAppELFSplitFileName) {}
1314

1415
FixtureTest::FixtureTest(std::string kernel_filename,
1516
std::string elf_filename,
1617
std::string elf_split_filename)
17-
: DartFixture(kernel_filename, elf_filename, elf_split_filename) {}
18+
: native_resolver_(std::make_shared<TestDartNativeResolver>()),
19+
split_aot_symbols_(
20+
LoadELFSplitSymbolFromFixturesIfNeccessary(elf_split_filename)),
21+
kernel_filename_(kernel_filename),
22+
assets_dir_(fml::OpenDirectory(GetFixturesPath(),
23+
false,
24+
fml::FilePermission::kRead)),
25+
aot_symbols_(LoadELFSymbolFromFixturesIfNeccessary(elf_filename)) {}
26+
27+
Settings FixtureTest::CreateSettingsForFixture() {
28+
Settings settings;
29+
settings.leak_vm = false;
30+
settings.task_observer_add = [](intptr_t, fml::closure) {};
31+
settings.task_observer_remove = [](intptr_t) {};
32+
settings.isolate_create_callback = [this]() {
33+
native_resolver_->SetNativeResolverForIsolate();
34+
};
35+
settings.enable_observatory = false;
36+
SetSnapshotsAndAssets(settings);
37+
return settings;
38+
}
39+
40+
void FixtureTest::SetSnapshotsAndAssets(Settings& settings) {
41+
if (!assets_dir_.is_valid()) {
42+
return;
43+
}
44+
45+
settings.assets_dir = assets_dir_.get();
46+
47+
// In JIT execution, all snapshots are present within the binary itself and
48+
// don't need to be explicitly supplied by the embedder. In AOT, these
49+
// snapshots will be present in the application AOT dylib.
50+
if (DartVM::IsRunningPrecompiledCode()) {
51+
FML_CHECK(PrepareSettingsForAOTWithSymbols(settings, aot_symbols_));
52+
} else {
53+
settings.application_kernels = [this]() -> Mappings {
54+
std::vector<std::unique_ptr<const fml::Mapping>> kernel_mappings;
55+
auto kernel_mapping =
56+
fml::FileMapping::CreateReadOnly(assets_dir_, kernel_filename_);
57+
if (!kernel_mapping || !kernel_mapping->IsValid()) {
58+
FML_LOG(ERROR) << "Could not find kernel blob for test fixture not "
59+
"running in precompiled mode.";
60+
return kernel_mappings;
61+
}
62+
kernel_mappings.emplace_back(std::move(kernel_mapping));
63+
return kernel_mappings;
64+
};
65+
}
66+
}
67+
68+
void FixtureTest::AddNativeCallback(std::string name,
69+
Dart_NativeFunction callback) {
70+
native_resolver_->AddNativeCallback(std::move(name), callback);
71+
}
1872

1973
} // namespace testing
2074
} // namespace flutter

0 commit comments

Comments
 (0)