Longest streak of no-spend days
Requirement
From one month of ledger transactions, find the longest streak
of consecutive July days with no spending at all (July 2026
has 31 days). Print a calendar strip marking each no-spend day with
#, then the streak length. The data is in the code below;
both versions must print the lines shown under
Expected output.
Expected output
July (# = no-spend day): ···###··######··#####·#####··## Longest no-spend streak: 6 days
Side by side
Native Dart
FxDart
Why they differ
A streak is a running value, and that is scan's exact
job: fold's every intermediate state, kept. The pipeline reads as the
definition — the days (range), mapped to
spent-or-not, scanned into a running streak that resets
on a spend day, and max picks the peak. The native loop
computes the same thing with two mutable counters and an
if — you verify it by mentally replaying iterations,
and the streak logic is fused to the strip-building beside it. In the
FxDart version the strip (map + join) and
the streak are two independent, separately readable pipelines over
the same range.
Benchmark
N = 100
Time Tie
Peak memory Tie
N = 10,000
Time Tie
Peak memory Tie
N = 1,000,000
Time Tie
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.