fps method

double fps(
  1. [int average = 1]
)

Returns the average FPS for the last average measures.

The values are only saved if in debug mode (override debugMode to use this). Selects the last average dts, averages then, and returns the inverse value. So it's technically updates per second, but the relation between updates and renders is 1:1. Returns 0 if empty.

Implementation

double fps([int average = 1]) {
  final List<double> dts = _dts.sublist(math.max(0, _dts.length - average));
  if (dts.isEmpty) {
    return 0.0;
  }
  final double dtSum = dts.reduce((s, t) => s + t);
  final double averageDt = dtSum / average;
  return 1 / averageDt;
}