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

End-of-day settlement pipeline

FxDart wins async

Requirement

Close out the day. From ten card transactions (in the code below): discard failed ones, group the rest by merchant, and net each merchant's total (refunds negative). Post each merchant's settlement to the bank gateway — at most two postings in flight, results in merchant order — then print the report: one line per merchant, a payout/collection split (one merchant's refunds exceed its captures), the grand total, and the max-in-flight proof.

This is the whole library in one pipeline. Sync prep: rejectgroupBysumBy per group → sortBy. Cross into async with toAsync, post under concurrent(2). Report with partition and sumBy again.

Expected output
2026-07-27 close — 3 merchants, 2 postings at a time:
  BookNook: 3 txns, net $-6.01
  Cafe Luna: 4 txns, net $32.00
  GadgetHub: 2 txns, net $218.90
payouts: 2, collections due: 1
settled: $244.89
max postings in flight: 2

Side by side

Native Dart

FxDart

Why they differ

Each half of this task has appeared in a smaller example; the point here is what happens when they meet. Native Dart does the prep well enough with package:collection (groupListsBy, sortedBy) — though netting each group is a fold with an explicit seed, and the payout split is two where passes. Then the async boundary hits, and the shape breaks: the bounded posting needs the worker pool, a separate named function with slots and a cursor, and the pipeline you were reading becomes plumbing you must trace. The FxDart version is one uninterrupted chain from raw transactions to posted settlements — fourteen lines where the policy (what is valid, how to group, how hard to hit the gateway) is the visible text, and the mechanics are the library's problem.

Benchmark

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

Async case: the headline scale is N = 100,000, not 1,000,000. Every element costs an event-loop turn on both sides, so a million real awaits would measure Dart's event loop for minutes — not the pipeline. Delays are zero-length and the example's concurrency limit is kept; what the bars compare is the pipeline machinery.

N = 100

Time Tie

Native Dart 38 µs
FxDart 35 µs

Peak memory Tie

Native Dart 16.5 MB
FxDart 16.7 MB

N = 10,000

Time FxDart wins

Native Dart 4.21 ms
FxDart 2.97 ms

Peak memory Native wins

Native Dart 23.1 MB
FxDart 24.4 MB

N = 100,000

Time FxDart wins

Native Dart 48.9 ms
FxDart 30.7 ms

Peak memory Tie

Native Dart 56.6 MB
FxDart 58.2 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.