Skip to content

Commit be7a422

Browse files
authored
Add a macrobenchmark for laying out text in a list (#104736)
1 parent 5cd979e commit be7a422

File tree

10 files changed

+167
-0
lines changed

10 files changed

+167
-0
lines changed

.ci.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,28 @@ targets:
19231923
task_name: multi_widget_construction_perf__e2e_summary
19241924
scheduler: luci
19251925

1926+
- name: Linux_android list_text_layout_perf__e2e_summary
1927+
recipe: devicelab/devicelab_drone
1928+
presubmit: false
1929+
timeout: 60
1930+
properties:
1931+
tags: >
1932+
["devicelab", "android", "linux"]
1933+
task_name: list_text_layout_perf__e2e_summary
1934+
scheduler: luci
1935+
bringup: true
1936+
1937+
- name: Linux_android list_text_layout_impeller_perf__e2e_summary
1938+
recipe: devicelab/devicelab_drone
1939+
presubmit: false
1940+
timeout: 60
1941+
properties:
1942+
tags: >
1943+
["devicelab", "android", "linux"]
1944+
task_name: list_text_layout_impeller_perf__e2e_summary
1945+
scheduler: luci
1946+
bringup: true
1947+
19261948
- name: Linux_android new_gallery__crane_perf
19271949
recipe: devicelab/devicelab_drone
19281950
presubmit: false

TESTOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
/dev/devicelab/bin/tasks/image_list_reported_duration.dart @zanderso @flutter/engine
6161
/dev/devicelab/bin/tasks/large_image_changer_perf_android.dart @zanderso @flutter/engine
6262
/dev/devicelab/bin/tasks/linux_chrome_dev_mode.dart @zanderso @flutter/tool
63+
/dev/devicelab/bin/tasks/list_text_layout_perf__e2e_summary.dart @dnfield @flutter/engine
64+
/dev/devicelab/bin/tasks/list_text_layout_impeller_perf__e2e_summary.dart @dnfield @flutter/engine
6365
/dev/devicelab/bin/tasks/multi_widget_construction_perf__e2e_summary.dart @zanderso @flutter/engine
6466
/dev/devicelab/bin/tasks/new_gallery__crane_perf.dart @zanderso @flutter/engine
6567
/dev/devicelab/bin/tasks/picture_cache_perf__e2e_summary.dart @zanderso @flutter/engine

dev/benchmarks/macrobenchmarks/lib/common.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const String kAnimatedImageRouteName = '/animated_image';
2929
const String kOpacityPeepholeRouteName = '/opacity_peephole';
3030
const String kGradientPerfRouteName = '/gradient_perf';
3131
const String kAnimatedComplexOpacityPerfRouteName = '/animated_complex_opacity';
32+
const String kListTextLayoutRouteName = '/list_text_layout';
3233

3334
const String kOpacityPeepholeOneRectRouteName = '$kOpacityPeepholeRouteName/one_big_rect';
3435
const String kOpacityPeepholeColumnOfOpacityRouteName = '$kOpacityPeepholeRouteName/column_of_opacity';

dev/benchmarks/macrobenchmarks/lib/main.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import 'src/gradient_perf.dart';
2222
import 'src/heavy_grid_view.dart';
2323
import 'src/large_image_changer.dart';
2424
import 'src/large_images.dart';
25+
import 'src/list_text_layout.dart';
2526
import 'src/multi_widget_construction.dart';
2627
import 'src/opacity_peephole.dart';
2728
import 'src/picture_cache.dart';
@@ -76,6 +77,7 @@ class MacrobenchmarksApp extends StatelessWidget {
7677
kGradientPerfRouteName: (BuildContext context) => const GradientPerfHomePage(),
7778
...gradientPerfRoutes,
7879
kAnimatedComplexOpacityPerfRouteName: (BuildContext context) => const AnimatedComplexOpacity(),
80+
kListTextLayoutRouteName: (BuildContext context) => const ColumnOfText(),
7981
},
8082
);
8183
}
@@ -275,6 +277,13 @@ class HomePage extends StatelessWidget {
275277
Navigator.pushNamed(context, kAnimatedComplexOpacityPerfRouteName);
276278
},
277279
),
280+
ElevatedButton(
281+
key: const Key(kListTextLayoutRouteName),
282+
child: const Text('A list with lots of text'),
283+
onPressed: () {
284+
Navigator.pushNamed(context, kListTextLayoutRouteName);
285+
},
286+
),
278287
],
279288
),
280289
);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
class ColumnOfText extends StatefulWidget {
8+
const ColumnOfText({super.key});
9+
10+
@override
11+
State<ColumnOfText> createState() => ColumnOfTextState();
12+
}
13+
14+
class ColumnOfTextState extends State<ColumnOfText> with SingleTickerProviderStateMixin {
15+
bool _showText = false;
16+
late AnimationController _controller;
17+
18+
@override
19+
void initState() {
20+
super.initState();
21+
_controller = AnimationController(
22+
vsync: this,
23+
duration: const Duration(milliseconds: 300),
24+
)
25+
..addStatusListener((AnimationStatus status) {
26+
if (status == AnimationStatus.completed) {
27+
setState(() {
28+
_showText = !_showText;
29+
});
30+
_controller
31+
..reset()
32+
..forward();
33+
}
34+
})
35+
..forward();
36+
}
37+
38+
@override
39+
void dispose() {
40+
_controller.dispose();
41+
super.dispose();
42+
}
43+
44+
@override
45+
Widget build(BuildContext context) {
46+
return Material(
47+
child: OverflowBox(
48+
alignment: Alignment.topCenter,
49+
maxHeight: double.infinity,
50+
child: !_showText
51+
? Container()
52+
: Column(
53+
children: List<Widget>.generate(9, (int index) {
54+
return ListTile(
55+
leading: CircleAvatar(
56+
child: Text('G$index'),
57+
),
58+
title: Text(
59+
'Foo contact from $index-th local contact',
60+
overflow: TextOverflow.ellipsis,
61+
),
62+
subtitle: Text('+91 88888 8800$index'),
63+
);
64+
}),
65+
),
66+
),
67+
);
68+
}
69+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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:macrobenchmarks/common.dart';
6+
7+
import 'util.dart';
8+
9+
void main() {
10+
macroPerfTestE2E(
11+
'list_text_layout',
12+
kListTextLayoutRouteName,
13+
pageDelay: const Duration(seconds: 1),
14+
duration: const Duration(seconds: 10),
15+
);
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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:macrobenchmarks/common.dart';
6+
7+
import 'util.dart';
8+
9+
void main() {
10+
macroPerfTest(
11+
'list_text_layout_perf',
12+
kListTextLayoutRouteName,
13+
pageDelay: const Duration(seconds: 1),
14+
duration: const Duration(seconds: 10),
15+
);
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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_devicelab/framework/devices.dart';
6+
import 'package:flutter_devicelab/framework/framework.dart';
7+
import 'package:flutter_devicelab/tasks/perf_tests.dart';
8+
9+
Future<void> main() async {
10+
deviceOperatingSystem = DeviceOperatingSystem.android;
11+
await task(createListTextLayoutPerfE2ETest());
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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_devicelab/framework/devices.dart';
6+
import 'package:flutter_devicelab/framework/framework.dart';
7+
import 'package:flutter_devicelab/tasks/perf_tests.dart';
8+
9+
Future<void> main() async {
10+
deviceOperatingSystem = DeviceOperatingSystem.android;
11+
await task(createListTextLayoutPerfE2ETest(enableImpeller: true));
12+
}

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,14 @@ TaskFunction createsMultiWidgetConstructPerfE2ETest() {
418418
).run;
419419
}
420420

421+
TaskFunction createListTextLayoutPerfE2ETest({bool enableImpeller = false}) {
422+
return PerfTest.e2e(
423+
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
424+
'test/list_text_layout_perf_e2e.dart',
425+
enableImpeller: enableImpeller,
426+
).run;
427+
}
428+
421429
TaskFunction createsScrollSmoothnessPerfTest() {
422430
final String testDirectory =
423431
'${flutterDirectory.path}/dev/benchmarks/complex_layout';

0 commit comments

Comments
 (0)