このページはまだ翻訳されていないため、英語で表示されます。 翻訳に参加する

Weekly averages from daily readings

FxDart wins

Requirement

A temperature sensor logged one reading per day for three full weeks (21 values). Report the average per 7-day week, one line per week, numbered from 1. The data is in the code below; both versions must print the lines shown under Expected output.

Expected output
Week 1: 21.3°C
Week 2: 25.0°C
Week 3: 20.5°C

Side by side

Native Dart

FxDart

Why they differ

"Split into groups of 7" has no core-Dart spelling, so the native version runs a counting loop and carves each week out with sublist(w * 7, w * 7 + 7) — index arithmetic that the reader must re-verify, and that breaks if the tail week is short. FxDart's chunk(7) says the grouping in one word (and handles a short tail), averageBy replaces the reduce-then-divide dance, and zipWithIndex brings the week number into the pipeline instead of borrowing the loop counter.

Benchmark

Apple M1 Max, 32 GB RAM · Dart 3.12.2 (AOT-compiled) · 2026-08-24

N = 98

Time Tie

Native Dart 4.2 µs
FxDart 4.5 µs

Peak memory Tie

Native Dart 16.5 MB
FxDart 16.5 MB

N = 9,996

Time Tie

Native Dart 396 µs
FxDart 464 µs

Peak memory Tie

Native Dart 22.7 MB
FxDart 22.7 MB

N = 999,999

Time Tie

Native Dart 49.1 ms
FxDart 48.5 ms

Peak memory Native wins

Native Dart 97.2 MB
FxDart 146.0 MB

Bars are medians of repeated timed iterations in fresh processes per side (small N is batched for timer resolution). Sides within 5% of each other — or within 0.6 ms, a difference no person can perceive — count as a tie; close relative races are re-measured up to 5 runs. In an app, anything under a few milliseconds is invisible to the user regardless of which bar is shorter. Memory is peak process RSS. The Dart VM and the dataset are identical on both sides, so the difference between the two bars is what the pipeline itself holds onto.