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

Three consecutive readings over the limit

FxDart wins

Requirement

Hourly CO2 readings for one day. Flag every window of three consecutive readings all above 1000 ppm — that means the ventilation could not catch up for three straight hours — and print each window as a start–end hour range under a header line. The data is in the code below; both versions must print the lines shown under Expected output.

Expected output
Ventilation alerts (3h over 1000 ppm):
11:00–13:00
15:00–17:00

Side by side

Native Dart

FxDart

Why they differ

Core Dart has no sliding window, so the native version is an index loop with an i + 2 < length bound and three manual lookups — correct, but every piece of it is bookkeeping a reader must check. The FxDart version builds the window as data: zip3 the list with itself shifted by one and by two (drop(1), drop(2)), and each element becomes a (reading, next, next-next) triple — no indices anywhere. zip3 stopping at the shortest input is exactly the window-fits-entirely rule the loop encodes as its bound. Widening the window to 4 hours is one more shifted input, not a re-audit of the arithmetic.

The shifted inputs are not copies. drop(n) over a List is a range of that list, and zip3 reads all three ranges by index — so the pipeline walks the readings once and allocates one triple per window, which is why its bar sits close to the loop rather than at a multiple of it.

Benchmark

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

N = 100

Time Tie

Native Dart 2.1 µs
FxDart 2.4 µs

Peak memory Tie

Native Dart 16.4 MB
FxDart 16.5 MB

N = 10,000

Time Tie

Native Dart 114 µs
FxDart 173 µs

Peak memory Native wins

Native Dart 20.5 MB
FxDart 23.5 MB

N = 1,000,000

Time Native wins

Native Dart 17.1 ms
FxDart 20.3 ms

Peak memory Tie

Native Dart 149.8 MB
FxDart 148.0 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.