Spending inside a date window
Requirement
A ledger export is already sorted by date. Total the spending between 2026-07-08 and 2026-07-21 inclusive — without scanning the whole list: skip entries before the window, take entries while still inside it, and sum what remains. The data is in the code below; both versions must print the line shown under Expected output.
Expected output
Spent 2026-07-08 to 2026-07-21: $104.04
Side by side
Native Dart
FxDart
Why they differ
Barely. Dart ships skipWhile and takeWhile on
every Iterable, and both are lazy — the plain-Dart version
exploits the sort order exactly the way the FxDart one does, and reads
just as well. The only real difference is the last step:
sumBy names the intent, where fold spells out
the seed and the combine. That is a one-word win, not a structural one —
call it a tie. If your codebase already chains with fx,
use it here for consistency; if not, plain Dart is fine.
Benchmark
N = 100
Time Tie
Peak memory FxDart wins
N = 10,000
Time Tie
Peak memory FxDart wins
N = 1,000,000
Time FxDart wins
Peak memory Tie
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.