Skip to content

Add web benchmark baseline comparison, ANSI summary table, and structured JSON helpers - #194609

Merged
auto-submit[bot] merged 13 commits into
flutter:masterfrom
harryterkelsen:web-benchmarks-part-3-pure-helpers-comprehensive
Oct 19, 2026
Merged

auto-submit[bot] merged 13 commits into
flutter:masterfrom
harryterkelsen:web-benchmarks-part-3-pure-helpers-comprehensive

Conversation

@harryterkelsen

Copy link
Copy Markdown
Contributor

Adds pure, unit-tested helpers in dev/devicelab/lib/tasks/web_benchmarks_comparison.dart that compare a web benchmark run against a saved baseline and print the result as a terminal table. A follow-up PR uses them in a local benchmark CLI.

  • compareResults compares the .average metrics that appear in both the current and the baseline TaskResult.data maps, sorted by key; all other keys are ignored. It computes each metric's percentage change and flags a regression when the change exceeds an optional regressionThreshold. Speedups are never regressions, and a metric that rises from zero has an infinite delta. Invalid thresholds throw ArgumentError, and compared values that are not finite, non-negative numbers throw FormatException.
  • formatAnsiSummaryTable prints a Metric / Baseline / Current / Delta / Status table with a header and separator row, right-aligned numbers, and an optionally ANSI-colored PASS/FAIL status.
  • Adds kSmokeTestBenchmarks to web_benchmarks.dart, the curated fast benchmark set (draw_rect, bench_card_infinite_scroll) for the CLI's --smoke-test flag.
  • Adds unit tests in dev/devicelab/test/tasks/web_benchmarks_test.dart: a table-driven matrix of delta and threshold cases (including zero baselines, no threshold and a delta equal to the threshold), key selection, input validation, and an exact expected-table test.

Part of #191316

Pre-launch Checklist

…nstead of asserting

Callers no longer need to pre-sort metrics; the public constructor copies
and sorts them, and exposes an unmodifiable list.
…ner needs

compareResults now compares only `.average` metrics present in both the
baseline and the current run. This removes the failOnMissingBaseline flag,
missingMetrics, current-only "new metric" rows and the nullable
baseline/current values, along with their N/A rendering.

Also removes:
- formatStructuredJson, since results are saved as the flattened
  TaskResult.data map.
- BenchmarkComparison.regressionThreshold, which had no readers.
- The sorting factory constructor; compareResults sorts the keys instead.

Simplifies the delta and regression computation and shortens the docs.

Tests:
- Delta and threshold cases are now one table-driven matrix. It adds
  coverage for no threshold, a delta equal to the threshold, an infinite
  threshold and null values.
- The hand-rolled table alignment checks are replaced by one exact
  expected-table string and an ANSI test.
@github-actions github-actions Bot added the team-web Owned by Web platform team label Oct 16, 2026
@harryterkelsen
harryterkelsen marked this pull request as ready for review October 17, 2026 00:13
@harryterkelsen harryterkelsen added the CICD Run CI/CD label Oct 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new utility for comparing web benchmark results. It adds kSmokeTestBenchmarks to web_benchmarks.dart and creates web_benchmarks_comparison.dart, which defines classes and functions (MetricComparison, BenchmarkComparison, compareResults, and formatAnsiSummaryTable) to compare baseline and current benchmark metrics, detect regressions based on a threshold, and format the results into an aligned ANSI-colored terminal table. Comprehensive unit tests for these comparison and formatting utilities are added in web_benchmarks_test.dart. There are no review comments, and I have no feedback to provide.

mdebbar
mdebbar previously approved these changes Oct 19, 2026
@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 19, 2026
@mdebbar
mdebbar removed this pull request from the merge queue due to a manual request Oct 19, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 19, 2026
@harryterkelsen
harryterkelsen removed this pull request from the merge queue due to a manual request Oct 19, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 19, 2026
Merged via the queue into flutter:master with commit 9eab636 Oct 19, 2026
24 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…ured JSON helpers (flutter#194609)

Adds pure, unit-tested helpers in
`dev/devicelab/lib/tasks/web_benchmarks_comparison.dart` that compare a
web benchmark run against a saved baseline and print the result as a
terminal table. A follow-up PR uses them in a local benchmark CLI.

- `compareResults` compares the `.average` metrics that appear in both
the current and the baseline `TaskResult.data` maps, sorted by key; all
other keys are ignored. It computes each metric's percentage change and
flags a regression when the change exceeds an optional
`regressionThreshold`. Speedups are never regressions, and a metric that
rises from zero has an infinite delta. Invalid thresholds throw
`ArgumentError`, and compared values that are not finite, non-negative
numbers throw `FormatException`.
- `formatAnsiSummaryTable` prints a `Metric` / `Baseline` / `Current` /
`Delta` / `Status` table with a header and separator row, right-aligned
numbers, and an optionally ANSI-colored `PASS`/`FAIL` status.
- Adds `kSmokeTestBenchmarks` to `web_benchmarks.dart`, the curated fast
benchmark set (`draw_rect`, `bench_card_infinite_scroll`) for the CLI's
`--smoke-test` flag.
- Adds unit tests in
`dev/devicelab/test/tasks/web_benchmarks_test.dart`: a table-driven
matrix of delta and threshold cases (including zero baselines, no
threshold and a delta equal to the threshold), key selection, input
validation, and an exact expected-table test.

Part of flutter#191316

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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 in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD team-web Owned by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants