本页尚未翻译,因此以英文显示。 参与翻译

Paginated product listing

Toss-up

Requirement

A small shop catalog: name, price, in-stock flag. Show page 2 of the in-stock products, sorted by price ascending, three per page — one line per product. The data is in the code below; both versions must print the lines shown under Expected output.

Expected output
Page 2 of in-stock products:
Milk Frother — $24.90
Cold Brew Jar — $27.80
Scale — $42.00

Side by side

Native Dart

FxDart

Why they differ

They barely do — this is a tie, and it is worth saying plainly. Pagination is exactly the shape Dart's Iterable already covers: skip and take read just as well as FxDart's drop and take, and both stay lazy. The only native wrinkle is sorting by a key — core Dart needs a comparator (package:collection's sortedBy closes even that). Pick FxDart here only if the rest of the codebase already speaks its vocabulary; plain Dart loses nothing on this task.

Benchmark

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

N = 100

Time Tie

Native Dart 5.9 µs
FxDart 6.5 µs

Peak memory Tie

Native Dart 16.5 MB
FxDart 17.1 MB

N = 10,000

Time Tie

Native Dart 815 µs
FxDart 818 µs

Peak memory Native wins

Native Dart 17.7 MB
FxDart 21.5 MB

N = 1,000,000

Time Native wins

Native Dart 101.3 ms
FxDart 111.9 ms

Peak memory Native wins

Native Dart 177.8 MB
FxDart 196.4 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.