mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add a macrobenchmark for laying out text in a list (#104736)
This commit is contained in:
parent
5cd979e441
commit
be7a4227c7
22
.ci.yaml
22
.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
|
||||
|
@ -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
|
||||
|
@ -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';
|
||||
|
@ -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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
69
dev/benchmarks/macrobenchmarks/lib/src/list_text_layout.dart
Normal file
69
dev/benchmarks/macrobenchmarks/lib/src/list_text_layout.dart
Normal file
@ -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<ColumnOfText> createState() => ColumnOfTextState();
|
||||
}
|
||||
|
||||
class ColumnOfTextState extends State<ColumnOfText> 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<Widget>.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'),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -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),
|
||||
);
|
||||
}
|
@ -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),
|
||||
);
|
||||
}
|
@ -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.android;
|
||||
await task(createListTextLayoutPerfE2ETest());
|
||||
}
|
@ -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.android;
|
||||
await task(createListTextLayoutPerfE2ETest(enableImpeller: true));
|
||||
}
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user