LCOV - code coverage report
Current view: top level - lib/src - fps_counter.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 8 0.0 %
Date: 2021-08-10 15:50:53 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/scheduler.dart';
       2             : 
       3             : import 'game/game.dart';
       4             : 
       5             : const _maxFrames = 60;
       6             : const frameInterval =
       7             :     Duration(microseconds: Duration.microsecondsPerSecond ~/ _maxFrames);
       8             : 
       9             : mixin FPSCounter on Game {
      10             :   List<FrameTiming> _previousTimings = [];
      11             : 
      12           0 :   @override
      13             :   void onTimingsCallback(List<FrameTiming> timings) =>
      14           0 :       _previousTimings = timings;
      15             : 
      16             :   /// Returns the FPS based on the frame times from [onTimingsCallback].
      17           0 :   double fps([int average = 1]) {
      18           0 :     return _previousTimings.length *
      19           0 :         _maxFrames /
      20           0 :         _previousTimings.map((t) {
      21           0 :           return (t.totalSpan.inMicroseconds ~/ frameInterval.inMicroseconds) +
      22             :               1;
      23           0 :         }).fold(0, (a, b) => a + b);
      24             :   }
      25             : }

Generated by: LCOV version 1.15