このページはまだ翻訳されていないため、英語で表示されます。 翻訳に参加する

Average order value over $100

Toss-up

Requirement

From a batch of shop orders, take only those totalling over $100 and print their average value as a currency amount. The data is in the code below; both versions must print the line shown under Expected output.

Expected output
Average large-order value: $203.81

Side by side

Native Dart

FxDart

Why they differ

Honestly: they don't, much — a tie. Core Dart alone would need a fold-and-count (or a sum divided by a length, walking the data twice), but package:collection's .average closes that gap, leaving where → map → average against filter → averageBy. FxDart saves the intermediate map by taking the key function directly, and averageBy is one word instead of an extension property on a projected iterable — vocabulary, not victory. Both read fine.

Benchmark

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

N = 100

Time Tie

Native Dart 2.0 µs
FxDart 787 ns

Peak memory Tie

Native Dart 16.5 MB
FxDart 16.4 MB

N = 10,000

Time Tie

Native Dart 185 µs
FxDart 83 µs

Peak memory FxDart wins

Native Dart 19.1 MB
FxDart 15.4 MB

N = 1,000,000

Time FxDart wins

Native Dart 17.3 ms
FxDart 8.79 ms

Peak memory Tie

Native Dart 75.2 MB
FxDart 72.9 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.