forked from firka/flutter
Add Benchmarks and examples to compare swiftui and flutter (#160681)
Partially addresses https://github.com/flutter/flutter/issues/154138, specifically [#162025](https://github.com/flutter/flutter/issues/162025), [#162026](https://github.com/flutter/flutter/issues/162026), [#162028](https://github.com/flutter/flutter/issues/162028), [#162029](https://github.com/flutter/flutter/issues/162029) ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
This commit is contained in:
12
dev/devicelab/bin/tasks/imitation_game_flutter__compile.dart
Normal file
12
dev/devicelab/bin/tasks/imitation_game_flutter__compile.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
await task(createImitationGameFlutterTest());
|
||||
}
|
||||
12
dev/devicelab/bin/tasks/imitation_game_swiftui__compile.dart
Normal file
12
dev/devicelab/bin/tasks/imitation_game_swiftui__compile.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
await task(createImitationGameSwiftUITest());
|
||||
}
|
||||
@@ -280,6 +280,28 @@ TaskFunction createHelloWorldCompileTest() {
|
||||
).run;
|
||||
}
|
||||
|
||||
TaskFunction createImitationGameSwiftUITest() {
|
||||
return CompileTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/imitation_game_swiftui',
|
||||
reportPackageContentSizes: true,
|
||||
).runSwiftUIApp;
|
||||
}
|
||||
|
||||
TaskFunction createImitationGameFlutterTest() {
|
||||
flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--platforms=ios',
|
||||
'${flutterDirectory.path}/dev/benchmarks/imitation_game_flutter',
|
||||
'--no-overwrite',
|
||||
],
|
||||
);
|
||||
return CompileTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/imitation_game_flutter',
|
||||
reportPackageContentSizes: true,
|
||||
).run;
|
||||
}
|
||||
|
||||
TaskFunction createWebCompileTest() {
|
||||
return const WebCompileTest().run;
|
||||
}
|
||||
@@ -1687,6 +1709,50 @@ class CompileTest {
|
||||
});
|
||||
}
|
||||
|
||||
Future<TaskResult> runSwiftUIApp() async {
|
||||
return inDirectory<TaskResult>(testDirectory, () async {
|
||||
await Process.run('xcodebuild', <String>['clean', '-allTargets']);
|
||||
|
||||
int releaseSizeInBytes = 0;
|
||||
final Stopwatch watch = Stopwatch();
|
||||
|
||||
watch.start();
|
||||
await Process.run(workingDirectory: testDirectory, 'xcodebuild', <String>[
|
||||
'-scheme',
|
||||
'hello_world_swiftui',
|
||||
'-target',
|
||||
'hello_world_swiftui',
|
||||
'-sdk',
|
||||
'iphoneos',
|
||||
'-configuration',
|
||||
'Release',
|
||||
'-archivePath',
|
||||
'$testDirectory/hello_world_swiftui',
|
||||
'archive',
|
||||
]).then((ProcessResult results) {
|
||||
watch.stop();
|
||||
print(results.stdout);
|
||||
if (results.exitCode != 0) {
|
||||
print(results.stderr);
|
||||
}
|
||||
});
|
||||
|
||||
final String appPath =
|
||||
'$testDirectory/hello_world_swiftui.xcarchive/Products/Applications/hello_world_swiftui.app';
|
||||
|
||||
// Zip up the .app file to get an approximation of the .ipa size.
|
||||
await exec('tar', <String>['-zcf', 'app.tar.gz', appPath]);
|
||||
releaseSizeInBytes = await file('$testDirectory/app.tar.gz').length();
|
||||
|
||||
final Map<String, dynamic> metrics = <String, dynamic>{};
|
||||
metrics.addAll(<String, dynamic>{
|
||||
'release_swiftui_compile_millis': watch.elapsedMilliseconds,
|
||||
'release_swiftui_size_bytes': releaseSizeInBytes,
|
||||
});
|
||||
return TaskResult.success(metrics);
|
||||
});
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> _compileApp({required bool deleteGradleCache}) async {
|
||||
await flutter('clean');
|
||||
if (deleteGradleCache) {
|
||||
|
||||
Reference in New Issue
Block a user