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

Categories over their monthly budget

FxDart wins

Requirement

Each spending category has a monthly budget. From July's transactions, total each category, keep only the categories that went over their budget, and print them worst offender first — spent, budget, and the overage on each line. The data is in the code below; both versions must print the lines shown under Expected output.

Expected output
Over budget in July:
Food: $135.75 spent, $120.00 budget (over by $15.75)
Fun: $34.75 spent, $30.00 budget (over by $4.75)
Bills: $90.33 spent, $90.00 budget (over by $0.33)

Side by side

Native Dart

FxDart

Why they differ

The formatting line is identical in both versions — the difference is everything before it. Native Dart does the grouping by hand in a mutable map, then switches idiom twice: a for loop to total, a where to filter, a cascade-sort with a hand-built comparator to rank. The FxDart version is one vocabulary end to end: groupBy, map to totals, filter against the budget, sortBy the overage, join. Each business rule — over budget, worst first — is one named step you can point at in a code review.

Benchmark

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

N = 100

Time Tie

Native Dart 3.8 µs
FxDart 3.6 µs

Peak memory Tie

Native Dart 16.5 MB
FxDart 16.6 MB

N = 10,000

Time Tie

Native Dart 185 µs
FxDart 90 µs

Peak memory FxDart wins

Native Dart 21.8 MB
FxDart 15.6 MB

N = 1,000,000

Time FxDart wins

Native Dart 21.5 ms
FxDart 13.0 ms

Peak memory FxDart wins

Native Dart 90.1 MB
FxDart 82.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.