Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
2bed4292
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
2bed4292
编写于
9月 08, 2021
作者:
K
Kaushik Iska
提交者:
GitHub
9月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Add benchmarks to measure dart -> native time (#28492)" (#28513)
上级
b13e3dd5
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
94 addition
and
251 deletion
+94
-251
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+0
-1
runtime/dart_isolate_unittests.cc
runtime/dart_isolate_unittests.cc
+10
-6
shell/common/BUILD.gn
shell/common/BUILD.gn
+1
-5
shell/common/dart_native_benchmarks.cc
shell/common/dart_native_benchmarks.cc
+0
-103
shell/common/fixtures/shell_test.dart
shell/common/fixtures/shell_test.dart
+0
-7
testing/BUILD.gn
testing/BUILD.gn
+0
-2
testing/dart_fixture.cc
testing/dart_fixture.cc
+0
-72
testing/dart_fixture.h
testing/dart_fixture.h
+0
-49
testing/fixture_test.cc
testing/fixture_test.cc
+58
-4
testing/fixture_test.h
testing/fixture_test.h
+25
-2
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
2bed4292
...
@@ -691,7 +691,6 @@ FILE: ../../../flutter/shell/common/canvas_spy.h
...
@@ -691,7 +691,6 @@ FILE: ../../../flutter/shell/common/canvas_spy.h
FILE: ../../../flutter/shell/common/canvas_spy_unittests.cc
FILE: ../../../flutter/shell/common/canvas_spy_unittests.cc
FILE: ../../../flutter/shell/common/context_options.cc
FILE: ../../../flutter/shell/common/context_options.cc
FILE: ../../../flutter/shell/common/context_options.h
FILE: ../../../flutter/shell/common/context_options.h
FILE: ../../../flutter/shell/common/dart_native_benchmarks.cc
FILE: ../../../flutter/shell/common/display.h
FILE: ../../../flutter/shell/common/display.h
FILE: ../../../flutter/shell/common/display_manager.cc
FILE: ../../../flutter/shell/common/display_manager.cc
FILE: ../../../flutter/shell/common/display_manager.h
FILE: ../../../flutter/shell/common/display_manager.h
...
...
runtime/dart_isolate_unittests.cc
浏览文件 @
2bed4292
...
@@ -247,9 +247,11 @@ TEST_F(DartIsolateTest, CanRunDartCodeCodeSynchronously) {
...
@@ -247,9 +247,11 @@ TEST_F(DartIsolateTest, CanRunDartCodeCodeSynchronously) {
TEST_F
(
DartIsolateTest
,
CanRegisterNativeCallback
)
{
TEST_F
(
DartIsolateTest
,
CanRegisterNativeCallback
)
{
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
AddNativeCallback
(
AddNativeCallback
(
"NotifyNative"
,
"NotifyNative"
,
CREATE_NATIVE_ENTRY
(([
this
](
Dart_NativeArguments
args
)
{
CREATE_NATIVE_ENTRY
(([
this
](
Dart_NativeArguments
args
)
{
Signal
();
})));
FML_LOG
(
ERROR
)
<<
"Hello from Dart!"
;
Signal
();
})));
const
auto
settings
=
CreateSettingsForFixture
();
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
thread
=
CreateNewThread
();
auto
thread
=
CreateNewThread
();
...
@@ -522,9 +524,11 @@ TEST_F(DartIsolateTest, DISABLED_ValidLoadingUnitSucceeds) {
...
@@ -522,9 +524,11 @@ TEST_F(DartIsolateTest, DISABLED_ValidLoadingUnitSucceeds) {
}
}
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
AddNativeCallback
(
AddNativeCallback
(
"NotifyNative"
,
"NotifyNative"
,
CREATE_NATIVE_ENTRY
(([
this
](
Dart_NativeArguments
args
)
{
CREATE_NATIVE_ENTRY
(([
this
](
Dart_NativeArguments
args
)
{
Signal
();
})));
FML_LOG
(
ERROR
)
<<
"Hello from Dart!"
;
Signal
();
})));
AddNativeCallback
(
AddNativeCallback
(
"NotifySuccess"
,
CREATE_NATIVE_ENTRY
([
this
](
Dart_NativeArguments
args
)
{
"NotifySuccess"
,
CREATE_NATIVE_ENTRY
([
this
](
Dart_NativeArguments
args
)
{
auto
bool_handle
=
Dart_GetNativeArgument
(
args
,
0
);
auto
bool_handle
=
Dart_GetNativeArgument
(
args
,
0
);
...
...
shell/common/BUILD.gn
浏览文件 @
2bed4292
...
@@ -158,17 +158,13 @@ if (enable_unittests) {
...
@@ -158,17 +158,13 @@ if (enable_unittests) {
}
}
shell_host_executable("shell_benchmarks") {
shell_host_executable("shell_benchmarks") {
sources = [
sources = [ "shell_benchmarks.cc" ]
"dart_native_benchmarks.cc",
"shell_benchmarks.cc",
]
deps = [
deps = [
":shell_unittests_fixtures",
":shell_unittests_fixtures",
"//flutter/benchmarking",
"//flutter/benchmarking",
"//flutter/flow",
"//flutter/flow",
"//flutter/testing:dart",
"//flutter/testing:dart",
"//flutter/testing:fixture_test",
"//flutter/testing:testing_lib",
"//flutter/testing:testing_lib",
]
]
}
}
...
...
shell/common/dart_native_benchmarks.cc
已删除
100644 → 0
浏览文件 @
b13e3dd5
// 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 "flutter/shell/common/shell.h"
#include "flutter/benchmarking/benchmarking.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/testing/dart_fixture.h"
#include "flutter/testing/dart_isolate_runner.h"
#include "flutter/testing/testing.h"
#include "fml/synchronization/count_down_latch.h"
#include "runtime/dart_vm_lifecycle.h"
namespace
flutter
::
testing
{
class
DartNativeBenchmarks
:
public
DartFixture
,
public
benchmark
::
Fixture
{
public:
DartNativeBenchmarks
()
:
DartFixture
()
{}
void
SetUp
(
const
::
benchmark
::
State
&
state
)
{}
void
TearDown
(
const
::
benchmark
::
State
&
state
)
{}
private:
FML_DISALLOW_COPY_AND_ASSIGN
(
DartNativeBenchmarks
);
};
BENCHMARK_F
(
DartNativeBenchmarks
,
TimeToFirstNativeMessageFromIsolateInNewVM
)
(
benchmark
::
State
&
st
)
{
while
(
st
.
KeepRunning
())
{
fml
::
AutoResetWaitableEvent
latch
;
st
.
PauseTiming
();
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
AddNativeCallback
(
"NotifyNative"
,
CREATE_NATIVE_ENTRY
(([
&
latch
](
Dart_NativeArguments
args
)
{
latch
.
Signal
();
})));
const
auto
settings
=
CreateSettingsForFixture
();
DartVMRef
vm_ref
=
DartVMRef
::
Create
(
settings
);
ThreadHost
thread_host
(
"io.flutter.test.DartNativeBenchmarks."
,
ThreadHost
::
Type
::
Platform
|
ThreadHost
::
Type
::
IO
|
ThreadHost
::
Type
::
UI
);
TaskRunners
task_runners
(
"test"
,
thread_host
.
platform_thread
->
GetTaskRunner
(),
// platform
thread_host
.
platform_thread
->
GetTaskRunner
(),
// raster
thread_host
.
ui_thread
->
GetTaskRunner
(),
// ui
thread_host
.
io_thread
->
GetTaskRunner
()
// io
);
{
st
.
ResumeTiming
();
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
task_runners
,
"notifyNative"
,
{},
GetDefaultKernelFilePath
());
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
latch
.
Wait
();
}
}
}
BENCHMARK_F
(
DartNativeBenchmarks
,
MultipleDartToNativeMessages
)
(
benchmark
::
State
&
st
)
{
while
(
st
.
KeepRunning
())
{
fml
::
CountDownLatch
latch
(
1000
);
st
.
PauseTiming
();
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
AddNativeCallback
(
"NotifyNative"
,
CREATE_NATIVE_ENTRY
(([
&
latch
](
Dart_NativeArguments
args
)
{
latch
.
CountDown
();
})));
const
auto
settings
=
CreateSettingsForFixture
();
DartVMRef
vm_ref
=
DartVMRef
::
Create
(
settings
);
ThreadHost
thread_host
(
"io.flutter.test.DartNativeBenchmarks."
,
ThreadHost
::
Type
::
Platform
|
ThreadHost
::
Type
::
IO
|
ThreadHost
::
Type
::
UI
);
TaskRunners
task_runners
(
"test"
,
thread_host
.
platform_thread
->
GetTaskRunner
(),
// platform
thread_host
.
platform_thread
->
GetTaskRunner
(),
// raster
thread_host
.
ui_thread
->
GetTaskRunner
(),
// ui
thread_host
.
io_thread
->
GetTaskRunner
()
// io
);
{
st
.
ResumeTiming
();
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
task_runners
,
"thousandCallsToNative"
,
{},
GetDefaultKernelFilePath
());
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
latch
.
Wait
();
}
}
}
}
// namespace flutter::testing
shell/common/fixtures/shell_test.dart
浏览文件 @
2bed4292
...
@@ -75,13 +75,6 @@ void sayHiFromFixturesAreFunctionalMain() native 'SayHiFromFixturesAreFunctional
...
@@ -75,13 +75,6 @@ void sayHiFromFixturesAreFunctionalMain() native 'SayHiFromFixturesAreFunctional
void
notifyNative
(
)
native
'NotifyNative'
;
void
notifyNative
(
)
native
'NotifyNative'
;
@pragma
(
'vm:entry-point'
)
void
thousandCallsToNative
(
)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
notifyNative
();
}
}
void
secondaryIsolateMain
(
String
message
)
{
void
secondaryIsolateMain
(
String
message
)
{
print
(
'Secondary isolate got message: '
+
message
);
print
(
'Secondary isolate got message: '
+
message
);
notifyNative
();
notifyNative
();
...
...
testing/BUILD.gn
浏览文件 @
2bed4292
...
@@ -92,8 +92,6 @@ source_set("fixture_test") {
...
@@ -92,8 +92,6 @@ source_set("fixture_test") {
testonly = true
testonly = true
sources = [
sources = [
"dart_fixture.cc",
"dart_fixture.h",
"fixture_test.cc",
"fixture_test.cc",
"fixture_test.h",
"fixture_test.h",
]
]
...
...
testing/dart_fixture.cc
已删除
100644 → 0
浏览文件 @
b13e3dd5
// 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 "flutter/testing/dart_fixture.h"
namespace
flutter
::
testing
{
DartFixture
::
DartFixture
()
:
DartFixture
(
"kernel_blob.bin"
,
kDefaultAOTAppELFFileName
,
kDefaultAOTAppELFSplitFileName
)
{}
DartFixture
::
DartFixture
(
std
::
string
kernel_filename
,
std
::
string
elf_filename
,
std
::
string
elf_split_filename
)
:
native_resolver_
(
std
::
make_shared
<
TestDartNativeResolver
>
()),
split_aot_symbols_
(
LoadELFSplitSymbolFromFixturesIfNeccessary
(
elf_split_filename
)),
kernel_filename_
(
kernel_filename
),
assets_dir_
(
fml
::
OpenDirectory
(
GetFixturesPath
(),
false
,
fml
::
FilePermission
::
kRead
)),
aot_symbols_
(
LoadELFSymbolFromFixturesIfNeccessary
(
elf_filename
))
{}
Settings
DartFixture
::
CreateSettingsForFixture
()
{
Settings
settings
;
settings
.
leak_vm
=
false
;
settings
.
task_observer_add
=
[](
intptr_t
,
fml
::
closure
)
{};
settings
.
task_observer_remove
=
[](
intptr_t
)
{};
settings
.
isolate_create_callback
=
[
this
]()
{
native_resolver_
->
SetNativeResolverForIsolate
();
};
settings
.
enable_observatory
=
false
;
SetSnapshotsAndAssets
(
settings
);
return
settings
;
}
void
DartFixture
::
SetSnapshotsAndAssets
(
Settings
&
settings
)
{
if
(
!
assets_dir_
.
is_valid
())
{
return
;
}
settings
.
assets_dir
=
assets_dir_
.
get
();
// In JIT execution, all snapshots are present within the binary itself and
// don't need to be explicitly supplied by the embedder. In AOT, these
// snapshots will be present in the application AOT dylib.
if
(
DartVM
::
IsRunningPrecompiledCode
())
{
FML_CHECK
(
PrepareSettingsForAOTWithSymbols
(
settings
,
aot_symbols_
));
}
else
{
settings
.
application_kernels
=
[
this
]()
->
Mappings
{
std
::
vector
<
std
::
unique_ptr
<
const
fml
::
Mapping
>>
kernel_mappings
;
auto
kernel_mapping
=
fml
::
FileMapping
::
CreateReadOnly
(
assets_dir_
,
kernel_filename_
);
if
(
!
kernel_mapping
||
!
kernel_mapping
->
IsValid
())
{
FML_LOG
(
ERROR
)
<<
"Could not find kernel blob for test fixture not "
"running in precompiled mode."
;
return
kernel_mappings
;
}
kernel_mappings
.
emplace_back
(
std
::
move
(
kernel_mapping
));
return
kernel_mappings
;
};
}
}
void
DartFixture
::
AddNativeCallback
(
std
::
string
name
,
Dart_NativeFunction
callback
)
{
native_resolver_
->
AddNativeCallback
(
std
::
move
(
name
),
callback
);
}
}
// namespace flutter::testing
testing/dart_fixture.h
已删除
100644 → 0
浏览文件 @
b13e3dd5
// 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_TESTING_DART_FIXTURE_H_
#define FLUTTER_TESTING_DART_FIXTURE_H_
#include <memory>
#include "flutter/common/settings.h"
#include "flutter/runtime/dart_vm.h"
#include "flutter/testing/elf_loader.h"
#include "flutter/testing/test_dart_native_resolver.h"
#include "flutter/testing/testing.h"
#include "flutter/testing/thread_test.h"
namespace
flutter
::
testing
{
class
DartFixture
{
public:
// Uses the default filenames from the fixtures generator.
DartFixture
();
// Allows to customize the kernel, ELF and split ELF filenames.
DartFixture
(
std
::
string
kernel_filename
,
std
::
string
elf_filename
,
std
::
string
elf_split_filename
);
virtual
Settings
CreateSettingsForFixture
();
void
AddNativeCallback
(
std
::
string
name
,
Dart_NativeFunction
callback
);
protected:
void
SetSnapshotsAndAssets
(
Settings
&
settings
);
std
::
shared_ptr
<
TestDartNativeResolver
>
native_resolver_
;
ELFAOTSymbols
split_aot_symbols_
;
std
::
string
kernel_filename_
;
std
::
string
elf_filename_
;
fml
::
UniqueFD
assets_dir_
;
ELFAOTSymbols
aot_symbols_
;
private:
FML_DISALLOW_COPY_AND_ASSIGN
(
DartFixture
);
};
}
// namespace flutter::testing
#endif // FLUTTER_TESTING_DART_FIXTURE_H_
testing/fixture_test.cc
浏览文件 @
2bed4292
...
@@ -4,17 +4,71 @@
...
@@ -4,17 +4,71 @@
#include "flutter/testing/fixture_test.h"
#include "flutter/testing/fixture_test.h"
#include "flutter/testing/dart_fixture.h"
namespace
flutter
{
namespace
flutter
{
namespace
testing
{
namespace
testing
{
FixtureTest
::
FixtureTest
()
:
DartFixture
()
{}
FixtureTest
::
FixtureTest
()
:
FixtureTest
(
"kernel_blob.bin"
,
kDefaultAOTAppELFFileName
,
kDefaultAOTAppELFSplitFileName
)
{}
FixtureTest
::
FixtureTest
(
std
::
string
kernel_filename
,
FixtureTest
::
FixtureTest
(
std
::
string
kernel_filename
,
std
::
string
elf_filename
,
std
::
string
elf_filename
,
std
::
string
elf_split_filename
)
std
::
string
elf_split_filename
)
:
DartFixture
(
kernel_filename
,
elf_filename
,
elf_split_filename
)
{}
:
native_resolver_
(
std
::
make_shared
<
TestDartNativeResolver
>
()),
split_aot_symbols_
(
LoadELFSplitSymbolFromFixturesIfNeccessary
(
elf_split_filename
)),
kernel_filename_
(
kernel_filename
),
assets_dir_
(
fml
::
OpenDirectory
(
GetFixturesPath
(),
false
,
fml
::
FilePermission
::
kRead
)),
aot_symbols_
(
LoadELFSymbolFromFixturesIfNeccessary
(
elf_filename
))
{}
Settings
FixtureTest
::
CreateSettingsForFixture
()
{
Settings
settings
;
settings
.
leak_vm
=
false
;
settings
.
task_observer_add
=
[](
intptr_t
,
fml
::
closure
)
{};
settings
.
task_observer_remove
=
[](
intptr_t
)
{};
settings
.
isolate_create_callback
=
[
this
]()
{
native_resolver_
->
SetNativeResolverForIsolate
();
};
settings
.
enable_observatory
=
false
;
SetSnapshotsAndAssets
(
settings
);
return
settings
;
}
void
FixtureTest
::
SetSnapshotsAndAssets
(
Settings
&
settings
)
{
if
(
!
assets_dir_
.
is_valid
())
{
return
;
}
settings
.
assets_dir
=
assets_dir_
.
get
();
// In JIT execution, all snapshots are present within the binary itself and
// don't need to be explicitly supplied by the embedder. In AOT, these
// snapshots will be present in the application AOT dylib.
if
(
DartVM
::
IsRunningPrecompiledCode
())
{
FML_CHECK
(
PrepareSettingsForAOTWithSymbols
(
settings
,
aot_symbols_
));
}
else
{
settings
.
application_kernels
=
[
this
]()
->
Mappings
{
std
::
vector
<
std
::
unique_ptr
<
const
fml
::
Mapping
>>
kernel_mappings
;
auto
kernel_mapping
=
fml
::
FileMapping
::
CreateReadOnly
(
assets_dir_
,
kernel_filename_
);
if
(
!
kernel_mapping
||
!
kernel_mapping
->
IsValid
())
{
FML_LOG
(
ERROR
)
<<
"Could not find kernel blob for test fixture not "
"running in precompiled mode."
;
return
kernel_mappings
;
}
kernel_mappings
.
emplace_back
(
std
::
move
(
kernel_mapping
));
return
kernel_mappings
;
};
}
}
void
FixtureTest
::
AddNativeCallback
(
std
::
string
name
,
Dart_NativeFunction
callback
)
{
native_resolver_
->
AddNativeCallback
(
std
::
move
(
name
),
callback
);
}
}
// namespace testing
}
// namespace testing
}
// namespace flutter
}
// namespace flutter
testing/fixture_test.h
浏览文件 @
2bed4292
...
@@ -5,12 +5,19 @@
...
@@ -5,12 +5,19 @@
#ifndef FLUTTER_TESTING_FIXTURE_TEST_H_
#ifndef FLUTTER_TESTING_FIXTURE_TEST_H_
#define FLUTTER_TESTING_FIXTURE_TEST_H_
#define FLUTTER_TESTING_FIXTURE_TEST_H_
#include "flutter/testing/dart_fixture.h"
#include <memory>
#include "flutter/common/settings.h"
#include "flutter/runtime/dart_vm.h"
#include "flutter/testing/elf_loader.h"
#include "flutter/testing/test_dart_native_resolver.h"
#include "flutter/testing/testing.h"
#include "flutter/testing/thread_test.h"
namespace
flutter
{
namespace
flutter
{
namespace
testing
{
namespace
testing
{
class
FixtureTest
:
public
DartFixture
,
public
ThreadTest
{
class
FixtureTest
:
public
ThreadTest
{
public:
public:
// Uses the default filenames from the fixtures generator.
// Uses the default filenames from the fixtures generator.
FixtureTest
();
FixtureTest
();
...
@@ -20,7 +27,23 @@ class FixtureTest : public DartFixture, public ThreadTest {
...
@@ -20,7 +27,23 @@ class FixtureTest : public DartFixture, public ThreadTest {
std
::
string
elf_filename
,
std
::
string
elf_filename
,
std
::
string
elf_split_filename
);
std
::
string
elf_split_filename
);
virtual
Settings
CreateSettingsForFixture
();
void
AddNativeCallback
(
std
::
string
name
,
Dart_NativeFunction
callback
);
protected:
void
SetSnapshotsAndAssets
(
Settings
&
settings
);
std
::
shared_ptr
<
TestDartNativeResolver
>
native_resolver_
;
ELFAOTSymbols
split_aot_symbols_
;
private:
private:
std
::
string
kernel_filename_
;
std
::
string
elf_filename_
;
fml
::
UniqueFD
assets_dir_
;
ELFAOTSymbols
aot_symbols_
;
FML_DISALLOW_COPY_AND_ASSIGN
(
FixtureTest
);
FML_DISALLOW_COPY_AND_ASSIGN
(
FixtureTest
);
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录