Terminal feed: on the web, show streaming output at most every 32 ms
In the browser a frame rasterises on the thread that parses output, so a stream drawn at 60 frames a second spends half its time drawing. With deferShows (the web default) output written less than a gap after the last show is shown when the gap has passed; output after a quiet spell (an echo) still shows at once. Natively frames rasterise on their own thread and written output keeps showing at once. The stream bench measures the stream without its final 600 ms wait for frame timings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -178,11 +178,12 @@ class _BenchState extends State<_Bench> {
|
||||
void _finish() {
|
||||
if (_done) return;
|
||||
_done = true;
|
||||
// The stream took this long; the wait below only collects timings.
|
||||
final seconds = _clock.elapsedMicroseconds / 1e6;
|
||||
// A last frame flushes the engine's batched timings.
|
||||
SchedulerBinding.instance.scheduleFrame();
|
||||
Timer(const Duration(milliseconds: 600), () {
|
||||
_clock.stop();
|
||||
final seconds = _clock.elapsedMicroseconds / 1e6;
|
||||
List<double> ms(Duration Function(FrameTiming t) pick) => [
|
||||
for (final t in _timings) pick(t).inMicroseconds / 1000,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user