Esta página ainda não foi traduzida, por isso é exibida em inglês. Ajude a traduzir

Batch users into pages of 10

FxDart wins

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

Apple M1 Max, 32 GB RAM · Dart 3.12.2 (AOT-compiled) · 2026-08-24

N = 100

Time Tie

Native Dart 9.4 µs
FxDart 7.3 µs

Peak memory Tie

Native Dart 16.4 MB
FxDart 16.5 MB

N = 10,000

Time Tie

Native Dart 754 µs
FxDart 628 µs

Peak memory Tie

Native Dart 22.9 MB
FxDart 23.5 MB

N = 1,000,000

Time FxDart wins

Native Dart 82.1 ms
FxDart 73.7 ms

Peak memory Tie

Native Dart 125.4 MB
FxDart 124.7 MB

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.