Batch users into pages of 10
Requirement
Split twelve users into pages of 10 (the last page may be short) and print each page on one line with its number, size, and names. The data is in the code below; both versions must print the lines shown under Expected output.
Expected output
Page 1, 10 users: Ava, Ben, Cara, Dan, Elle, Finn, Gus, Hana, Ivan, June Page 2, 2 users: Kai, Lena
Side by side
Native Dart
FxDart
Why they differ
Core Dart has no chunking at all — without help this is an index loop
over sublist with a min guard for the short
last page. package:collection's slices fixes
that, and if you already depend on it the two panels are nearly twins.
FxDart's edge is that chunk needs no extra dependency, is
lazy (pages materialize as you consume them), and the very same step
works on async chains — batching requests before a
concurrent stage is the classic use. A modest win, but a
real one.
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.