Эта страница ещё не переведена, поэтому показана на английском. Помогите с переводом

Compound interest table

FxDart wins

Requirement

Print a year-by-year balance table for $1000 at 5% compound interest over six years — one line per year, starting from the year-0 opening balance, each amount formatted to two decimals. The constants are in the code below; both versions must print the lines shown under Expected output.

Expected output
year 0: $1000.00
year 1: $1050.00
year 2: $1102.50
year 3: $1157.63
year 4: $1215.51
year 5: $1276.28
year 6: $1340.10

Side by side

Native Dart

FxDart

Why they differ

A running balance is a running fold, and core Dart has no word for it: fold gives only the final value, so the native version falls back to a loop that seeds a list with the year-0 line, mutates balance, and appends — the compounding rule, the iteration, and the formatting all share one body. FxDart's scan turns each intermediate balance into a value in the pipeline: the seed is the year-0 row, the compounding rule is one pure function, and formatting is a separate map step. Want the year the balance first passes $1200? Chain a filter — the loop version has to grow another flag instead.

Benchmark

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

N = 100

Time Tie

Native Dart 18 µs
FxDart 22 µs

Peak memory Tie

Native Dart 16.4 MB
FxDart 16.5 MB

N = 10,000

Time Tie

Native Dart 1.94 ms
FxDart 2.04 ms

Peak memory Tie

Native Dart 22.5 MB
FxDart 22.9 MB

N = 1,000,000

Time Native wins

Native Dart 221.7 ms
FxDart 244.5 ms

Peak memory Tie

Native Dart 126.6 MB
FxDart 128.6 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.