From a1423723fff778e5c02770d915837838cf19e08b Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Thu, 30 May 2024 16:37:47 -0700 Subject: [PATCH] Rounded Rect Blur Benchmark: Made the number of circles a fixed number (#149323) This will make the results more comparable across devices. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes --- dev/benchmarks/macrobenchmarks/lib/src/rrect_blur.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dev/benchmarks/macrobenchmarks/lib/src/rrect_blur.dart b/dev/benchmarks/macrobenchmarks/lib/src/rrect_blur.dart index dba0474afc..98ce4ae75d 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/rrect_blur.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/rrect_blur.dart @@ -11,10 +11,10 @@ class RRectBlur extends StatefulWidget { const RRectBlur({super.key}); @override - State createState() => _DrawPointsPageState(); + State createState() => _RRectBlurPageState(); } -class _DrawPointsPageState extends State +class _RRectBlurPageState extends State with SingleTickerProviderStateMixin { late final AnimationController controller; double tick = 0.0; @@ -73,7 +73,8 @@ class PointsPainter extends CustomPainter { } final double halfHeight = size.height / 2.0; const double freq = 0.25; - for (int i = 0; i < size.width / 10; ++i) { + const int circleCount = 40; + for (int i = 0; i < circleCount; ++i) { final double radius = 25 * cos(i + (1.0 * 2.0 * 3.1415 * tick) / 60.0) + 25; @@ -84,8 +85,9 @@ class PointsPainter extends CustomPainter { final double yval = halfHeight * sin(i + (freq * 2.0 * 3.1415 * tick) / 60.0) + halfHeight; + final double xval = (i.toDouble() / circleCount) * size.width; canvas.drawCircle( - Offset(10.0 * i, yval), + Offset(xval, yval), 50, paint..color = kColors[i % kColors.length], );