First 5 valid emails, normalized
Requirement
Signup input is messy: stray whitespace, mixed case, and a couple of
strings that are not emails at all. Normalize each entry (trim,
lowercase), keep only plausible emails (contains @ and a
dot), and print the first five. The data is in the code
below; both versions must print the lines shown under
Expected output.
Expected output
ada@example.com grace@hopper.dev lin@lang.org ken@unix.org dennis@unix.org
Side by side
Native Dart
FxDart
Why they differ
They don't, and that is the point. map, where,
and take ship on every Dart Iterable, they are
lazy, and the two versions are the same pipeline with where
spelled filter. For a short normalize-validate-truncate
chain like this, plain Dart is every bit as clear — reach for it. FxDart
earns its keep when the pipeline needs vocabulary Dart lacks
(groupBy, scan, zip,
concurrent…) or when the rest of the file already chains
with fx; adding a dependency for this snippet alone buys
nothing.
Benchmark
N = 100
Time Tie
Peak memory Tie
N = 10,000
Time Tie
Peak memory Tie
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.