startTracking method

void startTracking()

Start calculating the averageTPS measurement

Implementation

void startTracking() {
  final List<double> tps = [];

  _subscription =
      Stream<void>.periodic(const Duration(seconds: 1)).listen((_) {
    progress.removeWhere(
      (_, v) => v.timestamp
          .isBefore(DateTime.now().subtract(const Duration(seconds: 1))),
    );
    tps.add(progress.values.map((e) => e.progress).fold(0, (p, c) => p + c));

    _averageTPS = _calculateAverage(downloadSpeeds: tps);
  });
}