Skip to content

Commit ff1e9b7

Browse files
author
George Wright
authored
Add a benchmark for simple DisplayLists to exercise the Raster Cache's cache admission algorithm (flutter#97992)
1 parent e839375 commit ff1e9b7

8 files changed

+131
-0
lines changed

.ci.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,17 @@ targets:
20622062
task_name: picture_cache_perf__timeline_summary
20632063
scheduler: luci
20642064

2065+
- name: Linux_android picture_cache_complexity_scoring_perf__timeline_summary
2066+
recipe: devicelab/devicelab_drone
2067+
bringup: true
2068+
presubmit: false
2069+
timeout: 60
2070+
properties:
2071+
tags: >
2072+
["devicelab","android","linux"]
2073+
task_name: picture_cache_complexity_scoring_perf__timeline_summary
2074+
scheduler: luci
2075+
20652076
- name: Linux_android platform_channels_benchmarks
20662077
recipe: devicelab/devicelab_drone
20672078
presubmit: false
@@ -3371,6 +3382,17 @@ targets:
33713382
task_name: new_gallery_ios__transition_perf
33723383
scheduler: luci
33733384

3385+
- name: Mac_ios picture_cache_complexity_scoring_perf__timeline_summary
3386+
recipe: devicelab/devicelab_drone
3387+
bringup: true
3388+
presubmit: false
3389+
timeout: 60
3390+
properties:
3391+
tags: >
3392+
["devicelab","ios","mac"]
3393+
task_name: picture_cache_complexity_scoring_perf__timeline_summary
3394+
scheduler: luci
3395+
33743396
- name: Mac_ios platform_channel_sample_test_ios
33753397
recipe: devicelab/devicelab_drone
33763398
presubmit: false

TESTOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
/dev/devicelab/bin/tasks/microbenchmarks.dart @zanderso @flutter/engine
114114
/dev/devicelab/bin/tasks/new_gallery__transition_perf.dart @zanderso @flutter/engine
115115
/dev/devicelab/bin/tasks/picture_cache_perf__timeline_summary.dart @zanderso @flutter/engine
116+
/dev/devicelab/bin/tasks/picture_cache_complexity_scoring_perf__timeline_summary.dart @flar @flutter/engine
116117
/dev/devicelab/bin/tasks/platform_channel_sample_test.dart @zanderso @flutter/engine
117118
/dev/devicelab/bin/tasks/platform_interaction_test.dart @stuartmorgan @flutter/plugin
118119
/dev/devicelab/bin/tasks/platform_view__start_up.dart @zanderso @flutter/engine

dev/benchmarks/macrobenchmarks/lib/common.dart

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const String kBackdropFilterRouteName = '/backdrop_filter';
88
const String kPostBackdropFilterRouteName = '/post_backdrop_filter';
99
const String kSimpleAnimationRouteName = '/simple_animation';
1010
const String kPictureCacheRouteName = '/picture_cache';
11+
const String kPictureCacheComplexityScoringRouteName = '/picture_cache_complexity_scoring';
1112
const String kLargeImageChangerRouteName = '/large_image_changer';
1213
const String kLargeImagesRouteName = '/large_images';
1314
const String kTextRouteName = '/text';

dev/benchmarks/macrobenchmarks/lib/main.dart

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import 'src/large_images.dart';
2121
import 'src/multi_widget_construction.dart';
2222
import 'src/opacity_peephole.dart';
2323
import 'src/picture_cache.dart';
24+
import 'src/picture_cache_complexity_scoring.dart';
2425
import 'src/post_backdrop_filter.dart';
2526
import 'src/simple_animation.dart';
2627
import 'src/simple_scroll.dart';
@@ -47,6 +48,7 @@ class MacrobenchmarksApp extends StatelessWidget {
4748
kPostBackdropFilterRouteName: (BuildContext context) => const PostBackdropFilterPage(),
4849
kSimpleAnimationRouteName: (BuildContext context) => const SimpleAnimationPage(),
4950
kPictureCacheRouteName: (BuildContext context) => const PictureCachePage(),
51+
kPictureCacheComplexityScoringRouteName: (BuildContext context) => const PictureCacheComplexityScoringPage(),
5052
kLargeImageChangerRouteName: (BuildContext context) => const LargeImageChangerPage(),
5153
kLargeImagesRouteName: (BuildContext context) => const LargeImagesPage(),
5254
kTextRouteName: (BuildContext context) => const TextPage(),
@@ -122,6 +124,13 @@ class HomePage extends StatelessWidget {
122124
Navigator.pushNamed(context, kPictureCacheRouteName);
123125
},
124126
),
127+
ElevatedButton(
128+
key: const Key(kPictureCacheComplexityScoringRouteName),
129+
child: const Text('Picture Cache Complexity Scoring'),
130+
onPressed: () {
131+
Navigator.pushNamed(context, kPictureCacheComplexityScoringRouteName);
132+
},
133+
),
125134
ElevatedButton(
126135
key: const Key(kLargeImagesRouteName),
127136
child: const Text('Large Images'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 PictureCacheComplexityScoringPage extends StatelessWidget {
8+
const PictureCacheComplexityScoringPage({Key? key}) : super(key: key);
9+
10+
static const List<String> kTabNames = <String>['1', '2'];
11+
12+
@override
13+
Widget build(BuildContext context) {
14+
return DefaultTabController(
15+
length: kTabNames.length, // This is the number of tabs.
16+
child: Scaffold(
17+
appBar: AppBar(
18+
title: const Text('Picture Cache Complexity Scoring'),
19+
// pinned: true,
20+
// expandedHeight: 50.0,
21+
// forceElevated: innerBoxIsScrolled,
22+
bottom: TabBar(
23+
tabs: kTabNames.map((String name) => Tab(text: name)).toList(),
24+
),
25+
),
26+
body: TabBarView(
27+
key: const Key('tabbar_view_complexity'), // this key is used by the driver test
28+
children: kTabNames.map((String name) {
29+
return _buildComplexityScoringWidgets(name);
30+
}).toList(),
31+
),
32+
),
33+
);
34+
}
35+
36+
// For now we just test a single case where the widget being cached is actually
37+
// relatively cheap to rasterise, and so should not be in the cache.
38+
//
39+
// Eventually we can extend this to add new test cases based on the tab name.
40+
Widget _buildComplexityScoringWidgets(String name) {
41+
return Column(children: <Widget>[
42+
Slider(value: 50, label: 'Slider 1', onChanged: (double _) {}, max: 100, divisions: 10,),
43+
Slider(value: 50, label: 'Slider 2', onChanged: (double _) {}, max: 100, divisions: 10,),
44+
Slider(value: 50, label: 'Slider 3', onChanged: (double _) {}, max: 100, divisions: 10,),
45+
]);
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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_driver/flutter_driver.dart';
6+
import 'package:macrobenchmarks/common.dart';
7+
8+
import 'util.dart';
9+
10+
void main() {
11+
macroPerfTest(
12+
'picture_cache_complexity_scoring_perf',
13+
kPictureCacheComplexityScoringRouteName,
14+
pageDelay: const Duration(seconds: 1),
15+
driverOps: (FlutterDriver driver) async {
16+
final SerializableFinder tabBarView = find.byValueKey('tabbar_view_complexity');
17+
Future<void> _scrollOnce(double offset) async {
18+
// Technically it's not scrolling but moving
19+
await driver.scroll(tabBarView, offset, 0.0, const Duration(milliseconds: 300));
20+
await Future<void>.delayed(const Duration(milliseconds: 500));
21+
}
22+
// When we eventually add more test panes we will want to tweak these
23+
// to go through all the panes
24+
for (int i = 0; i < 6; i += 1) {
25+
await _scrollOnce(-300.0);
26+
await _scrollOnce(300.0);
27+
}
28+
},
29+
);
30+
}
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(createPictureCacheComplexityScoringPerfTest());
12+
}

dev/devicelab/lib/tasks/perf_tests.dart

+9
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ TaskFunction createPictureCachePerfE2ETest() {
215215
).run;
216216
}
217217

218+
TaskFunction createPictureCacheComplexityScoringPerfTest() {
219+
return PerfTest(
220+
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
221+
'test_driver/run_app.dart',
222+
'picture_cache_complexity_scoring_perf',
223+
testDriver: 'test_driver/picture_cache_complexity_scoring_perf_test.dart',
224+
).run;
225+
}
226+
218227
TaskFunction createFlutterGalleryStartupTest({String target = 'lib/main.dart'}) {
219228
return StartupTest(
220229
'${flutterDirectory.path}/dev/integration_tests/flutter_gallery',

0 commit comments

Comments
 (0)