Skip to content

Commit f0200f0

Browse files
authored
Add benchmark case for RasterCache (#103338)
1 parent 4c1d887 commit f0200f0

File tree

8 files changed

+188
-0
lines changed

8 files changed

+188
-0
lines changed

.ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,17 @@ targets:
13961396
task_name: color_filter_cache_perf__e2e_summary
13971397
scheduler: luci
13981398

1399+
- name: Linux_android raster_cache_use_memory_perf__e2e_summary
1400+
recipe: devicelab/devicelab_drone
1401+
presubmit: false
1402+
bringup: true
1403+
timeout: 60
1404+
properties:
1405+
tags: >
1406+
["devicelab","android","linux"]
1407+
task_name: raster_cache_use_memory_perf__e2e_summary
1408+
scheduler: luci
1409+
13991410
- name: Linux_android shader_mask_cache_perf__e2e_summary
14001411
recipe: devicelab/devicelab_drone
14011412
presubmit: false

TESTOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
/dev/devicelab/bin/tasks/platform_views_scroll_perf__timeline_summary.dart @zanderso @flutter/engine
7171
/dev/devicelab/bin/tasks/plugin_dependencies_test.dart @jmagman @flutter/tool
7272
/dev/devicelab/bin/tasks/routing_test.dart @zanderso @flutter/tool
73+
/dev/devicelab/bin/tasks/raster_cache_use_memory_perf__e2e_summary.dart @flar @flutter/engine
7374
/dev/devicelab/bin/tasks/textfield_perf__e2e_summary.dart @zanderso @flutter/engine
7475
/dev/devicelab/bin/tasks/web_size__compile_test.dart @yjbanov @flutter/web
7576
/dev/devicelab/bin/tasks/opacity_peephole_col_of_rows_perf__e2e_summary.dart @flar @flutter/engine

dev/benchmarks/macrobenchmarks/lib/common.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const String kFadingChildAnimationRouteName = '/fading_child_animation';
2121
const String kImageFilteredTransformAnimationRouteName = '/imagefiltered_transform_animation';
2222
const String kMultiWidgetConstructionRouteName = '/multi_widget_construction';
2323
const String kHeavyGridViewRouteName = '/heavy_gridview';
24+
const String kRasterCacheUseMemory = '/raster_cache_use_memory';
2425
const String kShaderMaskCacheRouteName = '/shader_mask_cache';
2526
const String kSimpleScrollRouteName = '/simple_scroll';
2627
const String kStackSizeRouteName = '/stack_size';

dev/benchmarks/macrobenchmarks/lib/main.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import 'src/opacity_peephole.dart';
2828
import 'src/picture_cache.dart';
2929
import 'src/picture_cache_complexity_scoring.dart';
3030
import 'src/post_backdrop_filter.dart';
31+
import 'src/raster_cache_use_memory.dart';
3132
import 'src/shader_mask_cache.dart';
3233
import 'src/simple_animation.dart';
3334
import 'src/simple_scroll.dart';
@@ -67,6 +68,7 @@ class MacrobenchmarksApp extends StatelessWidget {
6768
kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
6869
kMultiWidgetConstructionRouteName: (BuildContext context) => const MultiWidgetConstructTable(10, 20),
6970
kHeavyGridViewRouteName: (BuildContext context) => const HeavyGridViewPage(),
71+
kRasterCacheUseMemory: (BuildContext context) => const RasterCacheUseMemory(),
7072
kShaderMaskCacheRouteName: (BuildContext context) => const ShaderMaskCachePage(),
7173
kSimpleScrollRouteName: (BuildContext context) => const SimpleScroll(),
7274
kStackSizeRouteName: (BuildContext context) => const StackSizePage(),
@@ -193,6 +195,13 @@ class HomePage extends StatelessWidget {
193195
Navigator.pushNamed(context, kColorFilterCacheRouteName);
194196
},
195197
),
198+
ElevatedButton(
199+
key: const Key(kRasterCacheUseMemory),
200+
child: const Text('RasterCache Use Memory'),
201+
onPressed: () {
202+
Navigator.pushNamed(context, kRasterCacheUseMemory);
203+
},
204+
),
196205
ElevatedButton(
197206
key: const Key(kShaderMaskCacheRouteName),
198207
child: const Text('Shader Mask Cache'),
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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 'dart:async';
6+
import 'dart:ui';
7+
import 'package:flutter/material.dart';
8+
9+
class RasterCacheUseMemory extends StatefulWidget {
10+
const RasterCacheUseMemory({super.key});
11+
12+
@override
13+
State<RasterCacheUseMemory> createState() => _RasterCacheUseMemoryState();
14+
}
15+
16+
class _RasterCacheUseMemoryState extends State<RasterCacheUseMemory>
17+
with TickerProviderStateMixin {
18+
final ScrollController _controller = ScrollController();
19+
20+
@override
21+
void initState() {
22+
super.initState();
23+
_controller.addListener(() {
24+
if (_controller.offset < 5) {
25+
_controller.animateTo(20,
26+
duration: const Duration(milliseconds: 1000), curve: Curves.ease);
27+
} else if (_controller.offset >= 19) {
28+
_controller.animateTo(0,
29+
duration: const Duration(milliseconds: 1000), curve: Curves.ease);
30+
}
31+
});
32+
Timer(const Duration(milliseconds: 1000), () {
33+
_controller.animateTo(150,
34+
duration: const Duration(milliseconds: 1000), curve: Curves.ease);
35+
});
36+
}
37+
38+
@override
39+
Widget build(BuildContext context) {
40+
return Scaffold(
41+
backgroundColor: Colors.lightBlue,
42+
body: ListView(
43+
controller: _controller,
44+
children: <Widget>[
45+
RepaintBoundary(
46+
child: ImageFiltered(
47+
imageFilter: ImageFilter.blur(
48+
sigmaX: 4,
49+
sigmaY: 4,
50+
),
51+
child: RepaintBoundary(
52+
child: Container(
53+
width: 50,
54+
height: 50,
55+
color: Colors.red,
56+
),
57+
),
58+
),
59+
),
60+
ShaderMask(
61+
shaderCallback: (Rect bounds) {
62+
return const RadialGradient(
63+
center: Alignment.topLeft,
64+
radius: 1.0,
65+
colors: <Color>[Colors.yellow, Colors.deepOrange],
66+
tileMode: TileMode.mirror,
67+
).createShader(bounds);
68+
},
69+
blendMode: BlendMode.srcATop,
70+
child: Opacity(
71+
opacity: 0.5,
72+
child: Column(
73+
children: <Widget>[
74+
ImageFiltered(
75+
imageFilter: ImageFilter.blur(
76+
sigmaX: 4,
77+
sigmaY: 4,
78+
),
79+
child: Row(
80+
children: <Widget>[
81+
ImageFiltered(
82+
imageFilter: ImageFilter.blur(
83+
sigmaX: 4,
84+
sigmaY: 4,
85+
),
86+
child: RepaintBoundary(
87+
child: Container(
88+
margin: const EdgeInsets.fromLTRB(10, 5, 10, 5),
89+
decoration: BoxDecoration(
90+
color: Colors.white70,
91+
boxShadow: const <BoxShadow>[
92+
BoxShadow(
93+
blurRadius: 5.0,
94+
),
95+
],
96+
borderRadius: BorderRadius.circular(5.0),
97+
),
98+
child: const FlutterLogo(
99+
size: 50,
100+
),
101+
),
102+
),
103+
)
104+
],
105+
),
106+
)
107+
],
108+
),
109+
),
110+
),
111+
const RepaintBoundary(
112+
child: FlutterLogo(
113+
size: 50,
114+
),
115+
),
116+
Container(
117+
height: 800,
118+
),
119+
],
120+
),
121+
);
122+
}
123+
124+
@override
125+
void dispose() {
126+
_controller.dispose();
127+
super.dispose();
128+
}
129+
}
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+
'raster_cache_use_memory_perf',
12+
kRasterCacheUseMemory,
13+
pageDelay: const Duration(seconds: 1),
14+
duration: const Duration(seconds: 10),
15+
);
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 'dart:async';
6+
7+
import 'package:flutter_devicelab/framework/devices.dart';
8+
import 'package:flutter_devicelab/framework/framework.dart';
9+
import 'package:flutter_devicelab/tasks/perf_tests.dart';
10+
11+
Future<void> main() async {
12+
deviceOperatingSystem = DeviceOperatingSystem.android;
13+
await task(createRasterCacheUseMemoryPerfE2ETest());
14+
}

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ TaskFunction createColorFilterCachePerfE2ETest() {
384384
).run;
385385
}
386386

387+
TaskFunction createRasterCacheUseMemoryPerfE2ETest() {
388+
return PerfTest.e2e(
389+
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
390+
'test/raster_cache_use_memory_perf_e2e.dart',
391+
).run;
392+
}
393+
387394
TaskFunction createShaderMaskCachePerfE2ETest() {
388395
return PerfTest.e2e(
389396
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',

0 commit comments

Comments
 (0)