// Frame report for native fixture builds (the Linux desktop bench, // tool/perf/linux_desktop_bench.py), the native twin of frame_log.dart. // // With `perf=1` in FIXTURE_QUERY it prints every frame's Flutter timings as // `PERF_FRAME `, and the first rasterised // frame as `PERF_FIRST_FRAME_EPOCH `, which the // bench subtracts from its own launch time. Without the flag nothing is // installed. import 'package:flutter/widgets.dart'; void installNativeFrameLog(Map params) { if (params['perf'] != '1') return; final binding = WidgetsFlutterBinding.ensureInitialized(); binding.addTimingsCallback((timings) { for (final timing in timings) { // ignore: avoid_print print( 'PERF_FRAME ${timing.buildDuration.inMicroseconds} ' '${timing.rasterDuration.inMicroseconds} ' '${timing.totalSpan.inMicroseconds}', ); } }); binding.waitUntilFirstFrameRasterized.then((_) { // ignore: avoid_print print('PERF_FIRST_FRAME_EPOCH ${DateTime.now().millisecondsSinceEpoch}'); }); }