averageLatency property

Duration? get averageLatency

The average of the retained samples, or null if none exist yet.

Implementation

Duration? get averageLatency {
  if (_history.isEmpty) return null;
  final totalMicros = _history.fold<int>(
    0,
    (sum, d) => sum + d.inMicroseconds,
  );
  return Duration(microseconds: totalMicros ~/ _history.length);
}