From 41abe998ee37fb70fb3c86c5c2bbc3dcf2f1302c Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 15 May 2023 12:14:58 -0700 Subject: [PATCH] [devicelab] add drawPoints benchmark (#126728) Add a benchmark that measures the improvements from https://github.com/flutter/engine/pull/41803 --- .ci.yaml | 10 ++ TESTOWNERS | 1 + .../macrobenchmarks/lib/common.dart | 1 + dev/benchmarks/macrobenchmarks/lib/main.dart | 9 ++ .../macrobenchmarks/lib/src/draw_points.dart | 94 +++++++++++++++++++ .../test_driver/draw_points_perf_test.dart | 16 ++++ ...raw_points_perf_ios__timeline_summary.dart | 14 +++ dev/devicelab/lib/tasks/perf_tests.dart | 13 +++ 8 files changed, 158 insertions(+) create mode 100644 dev/benchmarks/macrobenchmarks/lib/src/draw_points.dart create mode 100644 dev/benchmarks/macrobenchmarks/test_driver/draw_points_perf_test.dart create mode 100644 dev/devicelab/bin/tasks/draw_points_perf_ios__timeline_summary.dart diff --git a/.ci.yaml b/.ci.yaml index 9b44d0c2f7..4d380c11e6 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -3955,6 +3955,16 @@ targets: ["devicelab", "ios", "mac"] task_name: animated_blur_backdrop_filter_perf_ios__timeline_summary + - name: Mac_ios draw_points_perf_ios__timeline_summary + recipe: devicelab/devicelab_drone + presubmit: false + bringup: true + timeout: 60 + properties: + tags: > + ["devicelab", "ios", "mac"] + task_name: draw_points_perf_ios__timeline_summary + - name: Mac_ios spell_check_test recipe: devicelab/devicelab_drone presubmit: false diff --git a/TESTOWNERS b/TESTOWNERS index 434ee6da9f..2b8547609c 100644 --- a/TESTOWNERS +++ b/TESTOWNERS @@ -199,6 +199,7 @@ /dev/devicelab/bin/tasks/simple_animation_perf_ios.dart @cyanglaz @flutter/engine /dev/devicelab/bin/tasks/tiles_scroll_perf_ios__timeline_summary.dart @cyanglaz @flutter/engine /dev/devicelab/bin/tasks/animated_blur_backdrop_filter_perf_ios__timeline_summary.dart @jonahwilliams @flutter/engine +/dev/devicelab/bin/tasks/draw_points_perf_ios__timeline_summary.dart @jonahwilliams @flutter/engine ## Host only DeviceLab tests /dev/devicelab/bin/tasks/animated_complex_opacity_perf_macos__e2e_summary.dart @cbracken @flutter/desktop diff --git a/dev/benchmarks/macrobenchmarks/lib/common.dart b/dev/benchmarks/macrobenchmarks/lib/common.dart index 92b47296f3..b8f158c8ca 100644 --- a/dev/benchmarks/macrobenchmarks/lib/common.dart +++ b/dev/benchmarks/macrobenchmarks/lib/common.dart @@ -35,6 +35,7 @@ const String kAnimatedComplexImageFilteredPerfRouteName = '/animated_complex_ima const String kListTextLayoutRouteName = '/list_text_layout'; const String kAnimatedBlurBackdropFilter = '/animated_blur_backdrop_filter'; const String kSlidersRouteName = '/sliders'; +const String kDrawPointsPageRougeName = '/draw_points'; const String kOpacityPeepholeOneRectRouteName = '$kOpacityPeepholeRouteName/one_big_rect'; const String kOpacityPeepholeColumnOfOpacityRouteName = '$kOpacityPeepholeRouteName/column_of_opacity'; diff --git a/dev/benchmarks/macrobenchmarks/lib/main.dart b/dev/benchmarks/macrobenchmarks/lib/main.dart index 2479e39280..464c792632 100644 --- a/dev/benchmarks/macrobenchmarks/lib/main.dart +++ b/dev/benchmarks/macrobenchmarks/lib/main.dart @@ -18,6 +18,7 @@ import 'src/color_filter_cache.dart'; import 'src/color_filter_with_unstable_child.dart'; import 'src/cubic_bezier.dart'; import 'src/cull_opacity.dart'; +import 'src/draw_points.dart'; import 'src/filtered_child_animation.dart'; import 'src/fullscreen_textfield.dart'; import 'src/gradient_perf.dart'; @@ -87,6 +88,7 @@ class MacrobenchmarksApp extends StatelessWidget { kAnimatedComplexImageFilteredPerfRouteName: (BuildContext context) => const AnimatedComplexImageFiltered(), kAnimatedBlurBackdropFilter: (BuildContext context) => const AnimatedBlurBackdropFilter(), kSlidersRouteName: (BuildContext context) => const SlidersPage(), + kDrawPointsPageRougeName: (BuildContext context) => const DrawPointsPage(), }, ); } @@ -328,6 +330,13 @@ class HomePage extends StatelessWidget { Navigator.pushNamed(context, kSlidersRouteName); }, ), + ElevatedButton( + key: const Key(kDrawPointsPageRougeName), + child: const Text('Draw Points'), + onPressed: () { + Navigator.pushNamed(context, kDrawPointsPageRougeName); + }, + ) ], ), ); diff --git a/dev/benchmarks/macrobenchmarks/lib/src/draw_points.dart b/dev/benchmarks/macrobenchmarks/lib/src/draw_points.dart new file mode 100644 index 0000000000..972238d4c0 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/lib/src/draw_points.dart @@ -0,0 +1,94 @@ +// 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:typed_data'; + +import 'package:flutter/material.dart'; + +import 'web/platform_views/web.dart'; + +class DrawPointsPage extends StatefulWidget { + const DrawPointsPage({super.key}); + + @override + State createState() => _DrawPointsPageState(); +} + +class _DrawPointsPageState extends State with SingleTickerProviderStateMixin { + late final AnimationController controller; + double tick = 0.0; + + @override + void initState() { + super.initState(); + controller = AnimationController(vsync: this, duration: const Duration(hours: 1)); + controller.addListener(() { + setState(() { + tick += 1; + }); + }); + controller.forward(from: 0); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + + @override + Widget build(BuildContext context) { + return CustomPaint( + size: const Size(500, 500), + painter: PointsPainter(tick), + child: Container(), + ); + } +} + +class PointsPainter extends CustomPainter { + PointsPainter(this.tick); + + final double tick; + + final Float32List data = Float32List(8000); + + static const List kColors = [ + Colors.red, + Colors.blue, + Colors.green, + Colors.yellow, + Colors.orange, + Colors.purple, + Colors.pink, + Colors.deepPurple, + ]; + + @override + void paint(Canvas canvas, Size size) { + if (size.width == 0) { + return; + } + canvas.drawPaint(Paint()..color = Colors.white); + for (int i = 0; i < 8; i++) { + final double x = ((size.width / i) + tick) % size.width; + for (int j = 0; j < data.length; j += 2) { + data[j] = x; + data[j + 1] = (size.height / j) + 200; + } + final Paint paint = Paint() + ..color = kColors[i] + ..strokeWidth = 5 + ..strokeCap = StrokeCap.round + ..style = PaintingStyle.stroke; + canvas.drawRawPoints(PointMode.points, data, paint); + } + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) { + return true; + } +} diff --git a/dev/benchmarks/macrobenchmarks/test_driver/draw_points_perf_test.dart b/dev/benchmarks/macrobenchmarks/test_driver/draw_points_perf_test.dart new file mode 100644 index 0000000000..b4824358a1 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/test_driver/draw_points_perf_test.dart @@ -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( + 'draw_points_perf', + kDrawPointsPageRougeName, + pageDelay: const Duration(seconds: 1), + duration: const Duration(seconds: 10), + ); +} diff --git a/dev/devicelab/bin/tasks/draw_points_perf_ios__timeline_summary.dart b/dev/devicelab/bin/tasks/draw_points_perf_ios__timeline_summary.dart new file mode 100644 index 0000000000..6d34f607f5 --- /dev/null +++ b/dev/devicelab/bin/tasks/draw_points_perf_ios__timeline_summary.dart @@ -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 main() async { + deviceOperatingSystem = DeviceOperatingSystem.ios; + await task(createDrawPointsPerfTest()); +} diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 91d8e846ce..04c846673b 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -638,6 +638,19 @@ TaskFunction createAnimatedBlurBackropFilterPerfTest({ ).run; } +TaskFunction createDrawPointsPerfTest({ + bool? enableImpeller, +}) { + return PerfTest( + '${flutterDirectory.path}/dev/benchmarks/macrobenchmarks', + 'test_driver/run_app.dart', + 'draw_points_perf', + enableImpeller: enableImpeller, + testDriver: 'test_driver/draw_points_perf_test.dart', + saveTraceFile: true, + ).run; +} + TaskFunction createAnimatedComplexOpacityPerfE2ETest({ bool? enableImpeller, }) {