From be7a4227c72715df0b5f6b07da4b1d63785c30f4 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 26 May 2022 15:25:10 -0700 Subject: [PATCH] Add a macrobenchmark for laying out text in a list (#104736) --- .ci.yaml | 22 ++++++ TESTOWNERS | 2 + .../macrobenchmarks/lib/common.dart | 1 + dev/benchmarks/macrobenchmarks/lib/main.dart | 9 +++ .../lib/src/list_text_layout.dart | 69 +++++++++++++++++++ .../test/list_text_layout_perf_e2e.dart | 16 +++++ .../list_text_layout_perf_test.dart | 16 +++++ ...ext_layout_impeller_perf__e2e_summary.dart | 12 ++++ .../list_text_layout_perf__e2e_summary.dart | 12 ++++ dev/devicelab/lib/tasks/perf_tests.dart | 8 +++ 10 files changed, 167 insertions(+) create mode 100644 dev/benchmarks/macrobenchmarks/lib/src/list_text_layout.dart create mode 100644 dev/benchmarks/macrobenchmarks/test/list_text_layout_perf_e2e.dart create mode 100644 dev/benchmarks/macrobenchmarks/test_driver/list_text_layout_perf_test.dart create mode 100644 dev/devicelab/bin/tasks/list_text_layout_impeller_perf__e2e_summary.dart create mode 100644 dev/devicelab/bin/tasks/list_text_layout_perf__e2e_summary.dart diff --git a/.ci.yaml b/.ci.yaml index ecb51a34ba..e8c9c6bfbf 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -1923,6 +1923,28 @@ targets: task_name: multi_widget_construction_perf__e2e_summary scheduler: luci + - name: Linux_android list_text_layout_perf__e2e_summary + recipe: devicelab/devicelab_drone + presubmit: false + timeout: 60 + properties: + tags: > + ["devicelab", "android", "linux"] + task_name: list_text_layout_perf__e2e_summary + scheduler: luci + bringup: true + + - name: Linux_android list_text_layout_impeller_perf__e2e_summary + recipe: devicelab/devicelab_drone + presubmit: false + timeout: 60 + properties: + tags: > + ["devicelab", "android", "linux"] + task_name: list_text_layout_impeller_perf__e2e_summary + scheduler: luci + bringup: true + - name: Linux_android new_gallery__crane_perf recipe: devicelab/devicelab_drone presubmit: false diff --git a/TESTOWNERS b/TESTOWNERS index b836a5931d..40ac0c6d94 100644 --- a/TESTOWNERS +++ b/TESTOWNERS @@ -60,6 +60,8 @@ /dev/devicelab/bin/tasks/image_list_reported_duration.dart @zanderso @flutter/engine /dev/devicelab/bin/tasks/large_image_changer_perf_android.dart @zanderso @flutter/engine /dev/devicelab/bin/tasks/linux_chrome_dev_mode.dart @zanderso @flutter/tool +/dev/devicelab/bin/tasks/list_text_layout_perf__e2e_summary.dart @dnfield @flutter/engine +/dev/devicelab/bin/tasks/list_text_layout_impeller_perf__e2e_summary.dart @dnfield @flutter/engine /dev/devicelab/bin/tasks/multi_widget_construction_perf__e2e_summary.dart @zanderso @flutter/engine /dev/devicelab/bin/tasks/new_gallery__crane_perf.dart @zanderso @flutter/engine /dev/devicelab/bin/tasks/picture_cache_perf__e2e_summary.dart @zanderso @flutter/engine diff --git a/dev/benchmarks/macrobenchmarks/lib/common.dart b/dev/benchmarks/macrobenchmarks/lib/common.dart index 39df4ce506..fe340cec8e 100644 --- a/dev/benchmarks/macrobenchmarks/lib/common.dart +++ b/dev/benchmarks/macrobenchmarks/lib/common.dart @@ -29,6 +29,7 @@ const String kAnimatedImageRouteName = '/animated_image'; const String kOpacityPeepholeRouteName = '/opacity_peephole'; const String kGradientPerfRouteName = '/gradient_perf'; const String kAnimatedComplexOpacityPerfRouteName = '/animated_complex_opacity'; +const String kListTextLayoutRouteName = '/list_text_layout'; const String kOpacityPeepholeOneRectRouteName = '$kOpacityPeepholeRouteName/one_big_rect'; const String kOpacityPeepholeColumnOfOpacityRouteName = '$kOpacityPeepholeRouteName/column_of_opacity'; diff --git a/dev/benchmarks/macrobenchmarks/lib/main.dart b/dev/benchmarks/macrobenchmarks/lib/main.dart index dd02537c40..356fbd5b07 100644 --- a/dev/benchmarks/macrobenchmarks/lib/main.dart +++ b/dev/benchmarks/macrobenchmarks/lib/main.dart @@ -22,6 +22,7 @@ import 'src/gradient_perf.dart'; import 'src/heavy_grid_view.dart'; import 'src/large_image_changer.dart'; import 'src/large_images.dart'; +import 'src/list_text_layout.dart'; import 'src/multi_widget_construction.dart'; import 'src/opacity_peephole.dart'; import 'src/picture_cache.dart'; @@ -76,6 +77,7 @@ class MacrobenchmarksApp extends StatelessWidget { kGradientPerfRouteName: (BuildContext context) => const GradientPerfHomePage(), ...gradientPerfRoutes, kAnimatedComplexOpacityPerfRouteName: (BuildContext context) => const AnimatedComplexOpacity(), + kListTextLayoutRouteName: (BuildContext context) => const ColumnOfText(), }, ); } @@ -275,6 +277,13 @@ class HomePage extends StatelessWidget { Navigator.pushNamed(context, kAnimatedComplexOpacityPerfRouteName); }, ), + ElevatedButton( + key: const Key(kListTextLayoutRouteName), + child: const Text('A list with lots of text'), + onPressed: () { + Navigator.pushNamed(context, kListTextLayoutRouteName); + }, + ), ], ), ); diff --git a/dev/benchmarks/macrobenchmarks/lib/src/list_text_layout.dart b/dev/benchmarks/macrobenchmarks/lib/src/list_text_layout.dart new file mode 100644 index 0000000000..af4e2a5365 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/lib/src/list_text_layout.dart @@ -0,0 +1,69 @@ +// 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/material.dart'; + +class ColumnOfText extends StatefulWidget { + const ColumnOfText({super.key}); + + @override + State createState() => ColumnOfTextState(); +} + +class ColumnOfTextState extends State with SingleTickerProviderStateMixin { + bool _showText = false; + late AnimationController _controller; + + @override + void initState() { + super.initState(); + _controller = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 300), + ) + ..addStatusListener((AnimationStatus status) { + if (status == AnimationStatus.completed) { + setState(() { + _showText = !_showText; + }); + _controller + ..reset() + ..forward(); + } + }) + ..forward(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Material( + child: OverflowBox( + alignment: Alignment.topCenter, + maxHeight: double.infinity, + child: !_showText + ? Container() + : Column( + children: List.generate(9, (int index) { + return ListTile( + leading: CircleAvatar( + child: Text('G$index'), + ), + title: Text( + 'Foo contact from $index-th local contact', + overflow: TextOverflow.ellipsis, + ), + subtitle: Text('+91 88888 8800$index'), + ); + }), + ), + ), + ); + } +} diff --git a/dev/benchmarks/macrobenchmarks/test/list_text_layout_perf_e2e.dart b/dev/benchmarks/macrobenchmarks/test/list_text_layout_perf_e2e.dart new file mode 100644 index 0000000000..f3326e4fdd --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/test/list_text_layout_perf_e2e.dart @@ -0,0 +1,16 @@ +// 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:macrobenchmarks/common.dart'; + +import 'util.dart'; + +void main() { + macroPerfTestE2E( + 'list_text_layout', + kListTextLayoutRouteName, + pageDelay: const Duration(seconds: 1), + duration: const Duration(seconds: 10), + ); +} diff --git a/dev/benchmarks/macrobenchmarks/test_driver/list_text_layout_perf_test.dart b/dev/benchmarks/macrobenchmarks/test_driver/list_text_layout_perf_test.dart new file mode 100644 index 0000000000..bf4a1b4543 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/test_driver/list_text_layout_perf_test.dart @@ -0,0 +1,16 @@ +// 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:macrobenchmarks/common.dart'; + +import 'util.dart'; + +void main() { + macroPerfTest( + 'list_text_layout_perf', + kListTextLayoutRouteName, + pageDelay: const Duration(seconds: 1), + duration: const Duration(seconds: 10), + ); +} diff --git a/dev/devicelab/bin/tasks/list_text_layout_impeller_perf__e2e_summary.dart b/dev/devicelab/bin/tasks/list_text_layout_impeller_perf__e2e_summary.dart new file mode 100644 index 0000000000..2060dc5fa5 --- /dev/null +++ b/dev/devicelab/bin/tasks/list_text_layout_impeller_perf__e2e_summary.dart @@ -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 main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(createListTextLayoutPerfE2ETest()); +} diff --git a/dev/devicelab/bin/tasks/list_text_layout_perf__e2e_summary.dart b/dev/devicelab/bin/tasks/list_text_layout_perf__e2e_summary.dart new file mode 100644 index 0000000000..2e4490df9c --- /dev/null +++ b/dev/devicelab/bin/tasks/list_text_layout_perf__e2e_summary.dart @@ -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 main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(createListTextLayoutPerfE2ETest(enableImpeller: true)); +} diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index ec2cdefd30..263c1fa3ae 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -418,6 +418,14 @@ TaskFunction createsMultiWidgetConstructPerfE2ETest() { ).run; } +TaskFunction createListTextLayoutPerfE2ETest({bool enableImpeller = false}) { + return PerfTest.e2e( + '${flutterDirectory.path}/dev/benchmarks/macrobenchmarks', + 'test/list_text_layout_perf_e2e.dart', + enableImpeller: enableImpeller, + ).run; +} + TaskFunction createsScrollSmoothnessPerfTest() { final String testDirectory = '${flutterDirectory.path}/dev/benchmarks/complex_layout';