forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a macrobenchmark for laying out text in a list (#104736)
- Loading branch information
Showing
10 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
dev/benchmarks/macrobenchmarks/lib/src/list_text_layout.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'), | ||
); | ||
}), | ||
), | ||
), | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
dev/benchmarks/macrobenchmarks/test/list_text_layout_perf_e2e.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
dev/benchmarks/macrobenchmarks/test_driver/list_text_layout_perf_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
dev/devicelab/bin/tasks/list_text_layout_impeller_perf__e2e_summary.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} |
12 changes: 12 additions & 0 deletions
12
dev/devicelab/bin/tasks/list_text_layout_perf__e2e_summary.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters