Add benchmark for ShaderMask RasterCache (#100127)

This commit is contained in:
wangying 2022-03-28 15:15:07 +08:00 committed by GitHub
parent 654aaa8eb2
commit 712abb08e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 140 additions and 1 deletions

View file

@ -1522,7 +1522,18 @@ targets:
tags: >
["devicelab","android","linux"]
task_name: color_filter_cache_perf__e2e_summary
benchmark: "true"
scheduler: luci
- name: Linux_android shader_mask_cache_perf__e2e_summary
bringup: true
recipe: devicelab/devicelab_drone
presubmit: false
timeout: 60
properties:
tags: >
["devicelab","android","linux"]
task_name: shader_mask_cache_perf__e2e_summary
scheduler: luci
- name: Linux_android complex_layout_android__compile
recipe: devicelab/devicelab_drone

View file

@ -23,6 +23,7 @@
/dev/devicelab/bin/tasks/basic_material_app_android__compile.dart @zanderso @flutter/tool
/dev/devicelab/bin/tasks/codegen_integration.dart @zanderso @flutter/tool
/dev/devicelab/bin/tasks/color_filter_and_fade_perf__e2e_summary.dart @zanderso @flutter/engine
/dev/devicelab/bin/tasks/shader_mask_cache_perf__e2e_summary.dart @flar @flutter/engine
/dev/devicelab/bin/tasks/color_filter_cache_perf__e2e_summary.dart @flar @flutter/engine
/dev/devicelab/bin/tasks/complex_layout_android__compile.dart @zanderso @flutter/tool
/dev/devicelab/bin/tasks/complex_layout_android__scroll_smoothness.dart @zanderso @flutter/engine

View file

@ -20,6 +20,7 @@ const String kFadingChildAnimationRouteName = '/fading_child_animation';
const String kImageFilteredTransformAnimationRouteName = '/imagefiltered_transform_animation';
const String kMultiWidgetConstructionRouteName = '/multi_widget_construction';
const String kHeavyGridViewRouteName = '/heavy_gridview';
const String kShaderMaskCacheRouteName = '/shader_mask_cache';
const String kSimpleScrollRouteName = '/simple_scroll';
const String kStackSizeRouteName = '/stack_size';
const String kAnimationWithMicrotasksRouteName = '/animation_with_microtasks';

View file

@ -24,6 +24,7 @@ import 'src/opacity_peephole.dart';
import 'src/picture_cache.dart';
import 'src/picture_cache_complexity_scoring.dart';
import 'src/post_backdrop_filter.dart';
import 'src/shader_mask_cache.dart';
import 'src/simple_animation.dart';
import 'src/simple_scroll.dart';
import 'src/stack_size.dart';
@ -61,6 +62,7 @@ class MacrobenchmarksApp extends StatelessWidget {
kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
kMultiWidgetConstructionRouteName: (BuildContext context) => const MultiWidgetConstructTable(10, 20),
kHeavyGridViewRouteName: (BuildContext context) => const HeavyGridViewPage(),
kShaderMaskCacheRouteName: (BuildContext context) => const ShaderMaskCachePage(),
kSimpleScrollRouteName: (BuildContext context) => const SimpleScroll(),
kStackSizeRouteName: (BuildContext context) => const StackSizePage(),
kAnimationWithMicrotasksRouteName: (BuildContext context) => const AnimationWithMicrotasks(),
@ -175,6 +177,13 @@ class HomePage extends StatelessWidget {
Navigator.pushNamed(context, kColorFilterCacheRouteName);
},
),
ElevatedButton(
key: const Key(kShaderMaskCacheRouteName),
child: const Text('Shader Mask Cache'),
onPressed: () {
Navigator.pushNamed(context, kShaderMaskCacheRouteName);
},
),
ElevatedButton(
key: const Key(kFadingChildAnimationRouteName),
child: const Text('Fading Child Animation'),

View file

@ -0,0 +1,80 @@
// 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 'dart:async';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'picture_cache.dart';
class ShaderMaskCachePage extends StatefulWidget {
const ShaderMaskCachePage({Key? key}) : super(key: key);
@override
State<ShaderMaskCachePage> createState() => _ShaderMaskCachePageState();
}
class _ShaderMaskCachePageState extends State<ShaderMaskCachePage>
with TickerProviderStateMixin {
final ScrollController _controller = ScrollController();
@override
void initState() {
super.initState();
_controller.addListener(() {
if (_controller.offset < 10) {
_controller.animateTo(100, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
} else if (_controller.offset > 90) {
_controller.animateTo(0, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
}
});
Timer(const Duration(milliseconds: 500), () {
_controller.animateTo(100, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.lightBlue,
body: ListView(
controller: _controller,
children: <Widget>[
const SizedBox(height: 100),
buildShaderMask(0),
const SizedBox(height: 10),
buildShaderMask(1),
const SizedBox(height: 1000),
],
),
);
}
Widget buildShaderMask(int index) {
return ShaderMask(
shaderCallback: (Rect bounds) {
return const RadialGradient(
center: Alignment.topLeft,
radius: 1.0,
colors: <Color>[Colors.yellow, Colors.red],
tileMode: TileMode.mirror,
).createShader(bounds);
},
child: Container(
clipBehavior: Clip.antiAlias,
decoration: const BoxDecoration(boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.white,
blurRadius: 5.0,
),
]),
child: ListItem(index: index),
),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}

View file

@ -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(
'shader_mask_cache_perf',
kShaderMaskCacheRouteName,
pageDelay: const Duration(seconds: 1),
duration: const Duration(seconds: 10),
);
}

View file

@ -0,0 +1,14 @@
// 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 'dart:async';
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(createShaderMaskCachePerfE2ETest());
}

View file

@ -378,6 +378,13 @@ TaskFunction createColorFilterCachePerfE2ETest() {
).run;
}
TaskFunction createShaderMaskCachePerfE2ETest() {
return PerfTest.e2e(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
'test/shader_mask_cache_perf_e2e.dart',
).run;
}
TaskFunction createFadingChildAnimationPerfTest() {
return PerfTest(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',