mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[devicelab] add drawPoints benchmark (#126728)
Add a benchmark that measures the improvements from https://github.com/flutter/engine/pull/41803
This commit is contained in:
parent
674b1ad0ae
commit
41abe998ee
10
.ci.yaml
10
.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
|
||||
|
@ -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
|
||||
|
@ -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';
|
||||
|
@ -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);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
94
dev/benchmarks/macrobenchmarks/lib/src/draw_points.dart
Normal file
94
dev/benchmarks/macrobenchmarks/lib/src/draw_points.dart
Normal file
@ -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<DrawPointsPage> createState() => _DrawPointsPageState();
|
||||
}
|
||||
|
||||
class _DrawPointsPageState extends State<DrawPointsPage> 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<Color> kColors = <Color>[
|
||||
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;
|
||||
}
|
||||
}
|
@ -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),
|
||||
);
|
||||
}
|
@ -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.ios;
|
||||
await task(createDrawPointsPerfTest());
|
||||
}
|
@ -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,
|
||||
}) {
|
||||
|
Loading…
Reference in New Issue
Block a user