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

Dart vs FxDart

The same real task, solved twice: plain Dart on the left, FxDart on the right. Both versions run in your browser and print exactly the same output — compare them and decide for yourself.

A word of honesty before the list: Dart's built-in Iterable is already lazy, and simple where/map chains are perfectly good Dart. FxDart is not here to beat those. What it adds is vocabulary (groupBy, chunk, zip, scan, uniqBy, partition — things core Dart makes you hand-roll), composition (one typed fx() chain instead of nested calls and intermediate variables), and above all concurrency control.concurrent(n) runs an async pipeline n items at a time, in order, which plain Dart can only approximate with manual worker pools. Every example carries a verdict badge, and some of them say native Dart is fine. That's the point: when an example does say FxDart wins, you can believe it.

FxDart wins — clearly better here · Toss-up — equally good, pick by taste · Native is fine — plain Dart handles it well · async — uses async pipelines

Две точки зрения на каждый пример: залитый бейдж оценивает код — какая версия приятнее в написании и чтении. Контурный бейдж ⚡ сообщает измерение — победителя по времени выполнения на наибольшем размере бенчмарка (AOT-компиляция); полные графики — в разделе Benchmark на каждой странице.

If you only read five, read these: #1 Top 3 largest expenses · #11 Top 5 merchants by total spend · #23 Enrich top merchants concurrently · #31 Multi-currency expense report · #53 Price drops between two snapshots

Part 1 · Two functions

Everyday one-liners. Native Dart often keeps up here — watch the verdict badges.

  1. 1 Top 3 largest expenses Toss-up ⚡ FxDart быстрее Largest three transactions of the month — sortedBy + take from package:collection vs sortBy + take in FxDart.
  2. 2 Most frequent log level FxDart wins ⚡ FxDart быстрее Count log entries per level and pick the biggest — groupListsBy + reduce in plain Dart vs countBy + maxBy in FxDart.
  3. 3 Load three remote configs in order FxDart wins async ⚡ Скорость одинакова Sequential async fetches — a plain await-in-loop in Dart vs toAsync + map in FxDart, one word away from bounded concurrency.
  4. 4 Average order value over $100 Toss-up ⚡ FxDart быстрее Mean total of large orders — where/map/average with package:collection vs filter + averageBy in FxDart.
  5. 5 Batch users into pages of 10 FxDart wins ⚡ FxDart быстрее Split a user list into fixed-size pages — slices from package:collection vs chunk + map in FxDart.
  6. 6 Rank labels for a leaderboard Toss-up ⚡ Скорость одинакова Number a sorted leaderboard 1..n — Dart 3 indexed records vs zipWithIndex + map in FxDart.
  7. 7 Running account balance FxDart wins ⚡ Нативный быстрее Balance after every transaction — a mutable accumulator loop in plain Dart vs scan + map in FxDart.
  8. 8 Food spending this month FxDart wins ⚡ FxDart быстрее Total one category of a ledger — a where/fold chain in plain Dart vs filter + sumBy in FxDart.
  9. 9 Merchants in first-visit order FxDart wins ⚡ Нативный быстрее Order-preserving dedupe — a seen-set loop in plain Dart vs map + uniq in FxDart.
  10. 10 First sensor reading over the limit Native is fine ⚡ Скорость одинакова Find the first temperature above a threshold — skipWhile + firstOrNull in plain Dart vs dropWhile + head in FxDart.

Part 2 · Three functions

Vocabulary native Dart lacks starts to pay off: groupBy, uniqBy, partition, scan.

  1. 11 Top 5 merchants by total spend FxDart wins ⚡ FxDart быстрее Group a ledger by merchant and rank the totals — groupListsBy + sortedBy in plain Dart vs one groupedBy → sortByDesc → take chain in FxDart.
  2. 12 All tags across posts, sorted Toss-up ⚡ FxDart быстрее Flatten post tags into one sorted, distinct list — expand + toSet + sort in plain Dart vs flatMap + uniq + sort in FxDart. A tie on the page, 1.5× on the clock.
  3. 13 Refunds vs charges, both formatted FxDart wins ⚡ FxDart быстрее Split a ledger into refunds and charges and print both sides — two where passes in plain Dart vs one partition in FxDart.
  4. 14 First 5 valid emails, normalized Native is fine ⚡ FxDart быстрее Trim, lowercase, validate, take five — map/where/take in plain Dart vs map + filter + take in FxDart. Plain Dart is every bit as clean here.
  5. 15 Fetch profiles, two at a time FxDart wins async ⚡ Нативный быстрее Bounded, in-order concurrency — a hand-rolled worker pool in plain Dart vs toAsync + map + concurrent in FxDart.
  6. 16 Compound interest table FxDart wins ⚡ Нативный быстрее A year-by-year balance table at 5% — a mutating accumulator loop in plain Dart vs range + scan + map in FxDart.
  7. 17 Category with highest average expense FxDart wins ⚡ Нативный быстрее Group expenses and find the priciest category per transaction — collection groupBy + maxBy nested calls in plain Dart vs one FxDart chain.
  8. 18 Spending inside a date window Toss-up ⚡ FxDart быстрее Sum a slice of a date-sorted ledger — skipWhile/takeWhile/fold in plain Dart vs dropWhile + takeWhile + sumBy in FxDart. Native holds up well.
  9. 19 Pair sensors with readings, keep anomalies FxDart wins ⚡ Нативный быстрее Join two parallel lists and flag hot readings — an index loop in plain Dart (core has no zip) vs zip + filter + map in FxDart.
  10. 20 Recent error messages, deduped FxDart wins ⚡ Нативный быстрее The three most recent distinct errors from a newest-first log — a seen-Set loop with a break in plain Dart vs filter + uniqBy + take in FxDart.

Part 3 · Five functions

Real reports and pipelines — where composition keeps multi-step logic readable.

  1. 21 Detect duplicated transactions FxDart wins ⚡ Скорость одинакова Flag charges with the same merchant, amount, and day — putIfAbsent plus nested loops in plain Dart vs groupBy + filter + flatMap in FxDart.
  2. 22 Longest streak of no-spend days FxDart wins ⚡ Скорость одинакова Longest run of July days with no transaction — loop with streak/longest counters in plain Dart vs range + scan + max in FxDart.
  3. 23 Enrich top merchants concurrently FxDart wins async ⚡ Нативный быстрее Pick the top 3 merchants, then look each up over a rate-limited API, 2 at a time — a hand-rolled worker pool in plain Dart vs concurrent(2) in FxDart.
  4. 24 Leaderboard with tied ranks FxDart wins ⚡ FxDart быстрее Rank players so equal scores share a rank — mutable rank/prevScore state in plain Dart vs sortBy + groupBy + zipWithIndex in FxDart.
  5. 25 Weekly averages from daily readings FxDart wins ⚡ Скорость одинакова Fold 21 daily readings into 3 weekly averages — index arithmetic and sublist in plain Dart vs chunk + averageBy + zipWithIndex in FxDart.
  6. 26 Paginated product listing Toss-up ⚡ Нативный быстрее Filter, sort by price, and slice out page 2 — Dart already has skip/take, so this one is a genuine tie.
  7. 27 Line items to invoice summary FxDart wins ⚡ FxDart быстрее Turn order line items into per-category totals plus a grand total — two loop-and-fold idioms in plain Dart vs groupBy + sumBy + sortBy in FxDart.
  8. 28 Categories over their monthly budget FxDart wins ⚡ FxDart быстрее Total spend per category, keep the ones over budget, rank by overage — mutable-map bookkeeping in plain Dart vs groupBy + filter + sortBy in FxDart.
  9. 29 Monthly category report, sorted by spend FxDart wins ⚡ Нативный быстрее Filter a ledger to one month, total each category, and rank them — loop plus mutable map in plain Dart vs filter + groupBy + sortBy in FxDart.
  10. 30 Three consecutive readings over the limit FxDart wins ⚡ Нативный быстрее Find every 3-hour window of CO2 readings all over 1000 ppm — an index loop in plain Dart vs a sliding window built from zip3 + drop in FxDart.

Part 4 · Six to ten functions

Full workflows, most with bounded concurrency — the part native Dart cannot express cleanly.

  1. 31 Multi-currency expense report FxDart wins ⚡ FxDart быстрее Normalize a trip ledger to USD with fixed rates, then group, rank, and summarize — one pipeline per report line vs fold/reduce boilerplate.
  2. 32 Inventory restock plan FxDart wins ⚡ FxDart быстрее Prioritize below-threshold items and cut the order list at a budget — scan + zip + takeWhile as data flow vs a mutable running total and break.
  3. 33 Concurrent price lookup with fallback FxDart wins async ⚡ Скорость одинакова Look up live prices 3 at a time, fall back to catalog prices for missing SKUs — concurrent + a null-coalescing map vs a worker pool.
  4. 34 Full monthly ledger report FxDart wins ⚡ FxDart быстрее One report string from a ledger — total, category breakdown, top merchants — as three fxdart pipelines vs loops and intermediate maps.
  5. 35 Fill gaps in a sparse time series FxDart wins ⚡ FxDart быстрее Days with no transactions become 0.00, then weekly rows with totals — range + groupBy + chunk as one flow vs a counting loop and slices.
  6. 36 Parallel downloads, results in order FxDart wins async ⚡ Нативный быстрее Six downloads with different speeds, 3 at a time — concurrent keeps request order even when completions interleave, vs pool bookkeeping.
  7. 37 Diff two ledger snapshots FxDart wins ⚡ Нативный быстрее Added, removed, and unchanged entries between two snapshots — differenceBy and intersectionBy by id vs hand-built id sets and where filters.
  8. 38 Poll a flaky API until first success FxDart wins async ⚡ Нативный быстрее Retry-until-ready as a lazy pipeline — range + toAsync + map + dropWhile + head vs an imperative polling loop with a break.
  9. 39 Log alert digest by service and severity FxDart wins ⚡ Скорость одинакова WARN and ERROR logs rendered as an indented digest — nested grouping via groupBy + flatMap + uniq vs three nested loops and a seen-set.
  10. 40 p50/p95 latency per endpoint FxDart wins ⚡ Скорость одинакова Percentile table from raw request logs — groupBy + sortBy + nth per endpoint vs a row-accumulating loop with in-place sorts.
  11. 41 Two paged feeds, concatenated and deduped FxDart wins async ⚡ Нативный быстрее Drain a primary log store, then its replica, dedupe by id, stop at 8 — concat + uniqBy + take stays lazy, vs nested loops with a seen-set.
  12. 42 Anomalies with surrounding context FxDart wins ⚡ FxDart быстрее Show over-limit sensor readings plus one line before and after — zipWithIndex + flatMap + uniq as one pipeline vs an index set built in nested loops.
  13. 43 Smoothed zone changes FxDart wins ⚡ FxDart быстрее Moving average, zone runs, transition alerts — three index loops with mutable carry in plain Dart vs windowed → uniqAdjacentBy → pairwise in FxDart.
  14. 44 Windowed alerts from a sensor stream FxDart wins async ⚡ Нативный быстрее Chunk a real Dart Stream into fixed windows and raise alerts — fromStream + chunk + averageBy vs manual buffer bookkeeping in await-for.
  15. 45 Live search over a keystroke stream FxDart wins async ⚡ Нативный быстрее Turn a stream of keystrokes into deduped backend searches — fromStream + filter + uniq + take + map vs await-for with guard clauses.
  16. 46 Rate-limited batch import FxDart wins async ⚡ Нативный быстрее Import 9 transactions in batches of 3, one batch at a time, with a running total — chunk + concurrent(1) + scan vs a sequential loop.
  17. 47 Rank the month by category FxDart wins ⚡ Скорость одинакова Group, total, and rank spending — groupListsBy plus a comparator swap in plain Dart vs one groupedBy → sortByDesc chain in FxDart.
  18. 48 Revalue the stock, three lookups at a time FxDart wins async ⚡ Нативный быстрее Live price lookups with a fallback — a worker pool plus hand-built pairs in plain Dart vs attach + concurrent + countWhere in FxDart.
  19. 49 Fetch 10 profiles, 3 at a time FxDart wins async ⚡ Скорость одинакова Sync prep flowing straight into bounded concurrency — filter and sort, then toAsync + map + concurrent(3), vs a hand-rolled worker pool.
  20. 50 Cohort retention table FxDart wins ⚡ Скорость одинакова Signup-month cohorts vs later activity — nested groupBy/dropWhile/filter pipelines vs nested for loops with accumulator lists.
  21. 51 Finale — DailyLedger monthly close FxDart wins async ⚡ Скорость одинакова The finale: load ledger entries 3 at a time, then compute the July summary and category breakdown — the real DailyLedger app shapes, both ways.
  22. 52 End-of-day settlement pipeline FxDart wins async ⚡ FxDart быстрее Validate, group by merchant, post 2 at a time, then report — one chain crossing sync to async, vs groupListsBy plus a worker pool.
  23. 53 Price drops between two snapshots FxDart wins ⚡ FxDart быстрее Compare two price-list snapshots and report what got cheaper — indexBy + filter + sortBy + head + sumBy vs a map literal and where/fold chains.