Skip to content

Commit 2c145ce

Browse files
authored
Add Benchmarks and examples to compare swiftui and flutter (#160681)
Partially addresses flutter/flutter#154138, specifically [#162025](flutter/flutter#162025), [#162026](flutter/flutter#162026), [#162028](flutter/flutter#162028), [#162029](flutter/flutter#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.
1 parent b8fd23c commit 2c145ce

File tree

22 files changed

+1046
-0
lines changed

22 files changed

+1046
-0
lines changed

.ci.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4852,6 +4852,26 @@ targets:
48524852
["devicelab", "ios", "mac", "arm64"]
48534853
task_name: hello_world_ios__compile
48544854

4855+
- name: Mac_arm64_ios imitation_game_flutter
4856+
recipe: devicelab/devicelab_drone
4857+
presubmit: false
4858+
bringup: true
4859+
timeout: 60
4860+
properties:
4861+
tags: >
4862+
["devicelab", "ios", "mac", "arm64"]
4863+
task_name: imitation_game_swiftui__compile
4864+
4865+
- name: Mac_arm64_ios imitation_game_swiftui
4866+
recipe: devicelab/devicelab_drone
4867+
presubmit: false
4868+
bringup: true
4869+
timeout: 60
4870+
properties:
4871+
tags: >
4872+
["devicelab", "ios", "mac", "arm64"]
4873+
task_name: imitation_game_flutter__compile
4874+
48554875
- name: Mac_x64 hot_mode_dev_cycle_macos_target__benchmark
48564876
recipe: devicelab/devicelab_drone
48574877
timeout: 60

TESTOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@
186186
/dev/devicelab/bin/tasks/fullscreen_textfield_perf_ios__e2e_summary.dart @louisehsu @flutter/engine
187187
/dev/devicelab/bin/tasks/hello_world_ios__compile.dart @jmagman @flutter/engine
188188
/dev/devicelab/bin/tasks/hot_mode_dev_cycle_ios__benchmark.dart @louisehsu @flutter/tool
189+
/dev/devicelab/bin/tasks/imitation_game_flutter__compile.dart @louisehsu @flutter/tool
190+
/dev/devicelab/bin/tasks/imitation_game_swiftui__compile.dart @louisehsu @flutter/tool
189191
# TODO(vashworth): Remove once https://github.com/flutter/flutter/issues/142305 is fixed.
190192
/dev/devicelab/bin/tasks/hot_mode_dev_cycle_ios__benchmark_no_dds.dart @louisehsu @flutter/tool
191193
/dev/devicelab/bin/tasks/imagefiltered_transform_animation_perf_ios__timeline_summary.dart @hellohuanlin @flutter/engine
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
**/doc/api/
28+
**/ios/Flutter/.last_build_id
29+
.dart_tool/
30+
.flutter-plugins
31+
.flutter-plugins-dependencies
32+
.pub-cache/
33+
.pub/
34+
/build/
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release
46+
47+
# Benchmark related
48+
/ios/
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "fea58103a27a000ee3c91851585e77336f65806f"
8+
channel: "[user-branch]"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: fea58103a27a000ee3c91851585e77336f65806f
17+
base_revision: fea58103a27a000ee3c91851585e77336f65806f
18+
- platform: ios
19+
create_revision: fea58103a27a000ee3c91851585e77336f65806f
20+
base_revision: fea58103a27a000ee3c91851585e77336f65806f
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is the example Flutter app used to compare performance to a equivalent SwiftUI app.
2+
See here for more info: https://github.com/flutter/flutter/issues/154138
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26+
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
7+
void main() {
8+
runApp(InfiniteScrollApp());
9+
}
10+
11+
class InfiniteScrollApp extends StatelessWidget {
12+
const InfiniteScrollApp({super.key});
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
return MaterialApp(
17+
title: 'Infinite Scrolling Flutter',
18+
home: InfiniteScrollList(),
19+
);
20+
}
21+
}
22+
23+
class InfiniteScrollList extends StatefulWidget {
24+
const InfiniteScrollList({super.key});
25+
26+
@override
27+
InfiniteScrollListState createState() => InfiniteScrollListState();
28+
}
29+
30+
class InfiniteScrollListState extends State<InfiniteScrollList> {
31+
final List<String> items = [];
32+
final int itemsPerPage = 20;
33+
final List<String> staticData = [
34+
"Hello Flutter",
35+
"Hello Flutter",
36+
"Hello Flutter",
37+
"Hello Flutter",
38+
"Hello Flutter",
39+
];
40+
41+
@override
42+
void initState() {
43+
super.initState();
44+
_loadMoreData(); // Load initial data
45+
}
46+
47+
void _loadMoreData() {
48+
setState(() {
49+
final newItems = List.generate(itemsPerPage, (i) {
50+
return staticData[i % staticData.length];
51+
});
52+
items.addAll(newItems);
53+
});
54+
}
55+
56+
@override
57+
Widget build(BuildContext context) {
58+
return MaterialApp(
59+
home: Scaffold(
60+
appBar: AppBar(
61+
title: Text("Infinite Scrolling ListView (Static Data)"),
62+
),
63+
body: NotificationListener<ScrollNotification>(
64+
onNotification: (ScrollNotification scrollInfo) {
65+
if (scrollInfo.metrics.pixels >=
66+
scrollInfo.metrics.maxScrollExtent - 50) {
67+
_loadMoreData();
68+
return true;
69+
}
70+
return false;
71+
},
72+
child: ListView.builder(
73+
itemCount: items.length,
74+
itemBuilder: (context, index) {
75+
return ListTile(title: Text(items[index]));
76+
},
77+
),
78+
),
79+
),
80+
);
81+
}
82+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: hello_world_flutter
2+
description: "A new Flutter project."
3+
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
4+
version: 1.0.0+1
5+
6+
environment:
7+
sdk: ^3.7.0-208.0.dev
8+
9+
dependencies:
10+
flutter:
11+
sdk: flutter
12+
13+
cupertino_icons: 1.0.8
14+
15+
characters: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
16+
collection: 1.19.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
17+
material_color_utilities: 0.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
18+
meta: 1.16.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
19+
vector_math: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
20+
21+
dev_dependencies:
22+
flutter_test:
23+
sdk: flutter
24+
flutter_lints: 5.0.0
25+
26+
async: 2.12.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
27+
boolean_selector: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
28+
clock: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
29+
fake_async: 1.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
30+
leak_tracker: 10.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
31+
leak_tracker_flutter_testing: 3.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
32+
leak_tracker_testing: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
33+
lints: 5.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
34+
matcher: 0.12.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
35+
path: 1.9.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
36+
source_span: 1.10.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
37+
stack_trace: 1.12.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
38+
stream_channel: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
39+
string_scanner: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
40+
term_glyph: 1.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
41+
test_api: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
42+
vm_service: 15.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
43+
44+
flutter:
45+
uses-material-design: true
46+
47+
# PUBSPEC CHECKSUM: 1f28
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>destination</key>
6+
<string>export</string>
7+
<key>method</key>
8+
<string>ad-hoc</string>
9+
<key>signingStyle</key>
10+
<string>automatic</string>
11+
<key>stripSwiftSymbols</key>
12+
<true/>
13+
<key>teamID</key>
14+
<string>S8QB4VV633</string>
15+
<key>thinning</key>
16+
<string>&lt;none&gt;</string>
17+
</dict>
18+
</plist>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is the example SwiftUI app used to compare performance to a equivalent Flutter app.
2+
See here for more info: https://github.com/flutter/flutter/issues/154138

0 commit comments

Comments
 (0)