Skip to content

Commit

Permalink
Rounded Rect Blur Benchmark: Made the number of circles a fixed number (
Browse files Browse the repository at this point in the history
flutter#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].

<!-- Links -->
[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
  • Loading branch information
gaaclarke authored May 30, 2024
1 parent d89ae48 commit a142372
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions dev/benchmarks/macrobenchmarks/lib/src/rrect_blur.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class RRectBlur extends StatefulWidget {
const RRectBlur({super.key});

@override
State<RRectBlur> createState() => _DrawPointsPageState();
State<RRectBlur> createState() => _RRectBlurPageState();
}

class _DrawPointsPageState extends State<RRectBlur>
class _RRectBlurPageState extends State<RRectBlur>
with SingleTickerProviderStateMixin {
late final AnimationController controller;
double tick = 0.0;
Expand Down Expand Up @@ -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;
Expand All @@ -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],
);
Expand Down

0 comments on commit a142372

Please sign in to comment.