Food spending this month

FxDart wins

Requirement

Given a month of ledger transactions — each with a date, category, merchant, and amount — total what was spent in the Food category, and print it as a currency amount. The data is in the code below; both versions must print the line shown under Expected output.

Expected output
Food spending: $84.40

Side by side

Native Dart

FxDart

Why they differ

Native Dart has no "sum of a field" — you either mutate an accumulator in a for loop or reach for fold with an explicit seed and combine step. FxDart's sumBy says the intent in one word, and the filter → sumBy chain reads in the order the data flows. The gap is small on a two-step task — it widens as steps are added.

Benchmark

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

N = 100

Time Tie

Native Dart 1.2 µs
FxDart 833 ns

Peak memory Tie

Native Dart 16.5 MB
FxDart 16.5 MB

N = 10,000

Time Tie

Native Dart 147 µs
FxDart 100 µs

Peak memory FxDart wins

Native Dart 17.0 MB
FxDart 15.6 MB

N = 1,000,000

Time FxDart wins

Native Dart 12.6 ms
FxDart 11.4 ms

Peak memory FxDart wins

Native Dart 91.0 MB
FxDart 85.1 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.