mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Train frontend_server snapshot (flutter/engine#4512)
Cuts 30% from hot-reload benchmarks with `--preview-dart-2`
This commit is contained in:
parent
2ad5b735d0
commit
d7e7abbcc2
@ -7,7 +7,8 @@ import("//third_party/dart/utils/application_snapshot.gni")
|
||||
application_snapshot("frontend_server") {
|
||||
main_dart = "bin/starter.dart"
|
||||
dot_packages = rebase_path(".packages")
|
||||
training_args = [ "--train" ]
|
||||
flutter_patched_sdk = rebase_path("$root_out_dir/flutter_patched_sdk")
|
||||
training_args = [ "--train", "--sdk-root=$flutter_patched_sdk" ]
|
||||
|
||||
frontend_server_files = exec_script("//third_party/dart/tools/list_dart_files.py",
|
||||
[ "absolute", rebase_path("."), ], "list lines")
|
||||
|
||||
@ -261,6 +261,17 @@ Future<int> starter(
|
||||
}
|
||||
|
||||
if (options['train']) {
|
||||
final String sdkRoot = options['sdk-root'];
|
||||
options = _argParser.parse(<String>['--incremental', '--sdk-root=$sdkRoot']);
|
||||
compiler ??= new _FrontendCompiler(output, printerFactory: binaryPrinterFactory);
|
||||
await compiler.compile(Platform.script.toFilePath(), options, generator: generator);
|
||||
compiler.acceptLastDelta();
|
||||
await compiler.recompileDelta();
|
||||
compiler.acceptLastDelta();
|
||||
await compiler.recompileDelta();
|
||||
compiler.acceptLastDelta();
|
||||
await compiler.recompileDelta();
|
||||
compiler.acceptLastDelta();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -26,8 +26,10 @@ class _MockedBinaryPrinter extends Mock implements BinaryPrinter {}
|
||||
|
||||
Future<int> main() async {
|
||||
group('basic', () {
|
||||
test('train completes', () async {
|
||||
expect(await starter(<String>['--train']), equals(0));
|
||||
final CompilerInterface compiler = new _MockedCompiler();
|
||||
|
||||
test('train with mocked compiler completes', () async {
|
||||
expect(await starter(<String>['--train'], compiler: compiler), equals(0));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user