Fastest result first
Requirement
Run six user lookups with distinct response times, at most 3 at once, and report the results in completion order — the fastest lookup prints first, regardless of where it sat in the input. The delays are chosen so the order is stable (user 2, then 1, 4, 3, 5, 6). The data is in the code; both versions must print the lines shown under Expected output.
Expected output
user#2 user#1 user#4 user#3 user#5 user#6
Side by side
RxDart
FxDart
Why they differ
This is the mirror image of the previous example, and the verdict
flips to even. Completion order is what a merge is: RxDart's
flatMap(maxConcurrent: 3) subscribes to three inner
streams and forwards whichever fires first, so "fastest first, three
at a time" is the operator's literal behavior — nothing to add,
nothing to undo.
A pull pipeline's default is the opposite — results come back in the
order they were demanded — so FxDart offers completion order as a
named variant: concurrentPool(3) keeps three pulls open
and yields whichever resolves first, exactly like the merge. Each
library reaches this requirement in one operator; the only real
difference is which behavior each model gets for free and which one
it had to name. Pick by the order you need — mapConcurrent
when results must line up with inputs, flatMap /
concurrentPool when latency to first result matters more.
Benchmark
Async case: the headline scale is N = 10,000, not 1,000,000. Every element costs an event-loop turn on both sides, so a million real awaits would measure Dart's event loop for minutes — not the pipeline. Delays are zero-length and the example's concurrency limit is kept; what the bars compare is the pipeline machinery.
N = 100
Time Tie
Peak memory Tie
N = 10,000
Time Tie
Peak memory FxDart wins
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.