toMetricsJson method
Implementation
Map<String, dynamic> toMetricsJson() {
final fpsAvg = _fpsHistory.isEmpty
? 0.0
: _fpsHistory.reduce((a, b) => a + b) / _fpsHistory.length;
final memAvg = _memoryHistory.isEmpty
? 0.0
: _memoryHistory.reduce((a, b) => a + b) / _memoryHistory.length;
final uptime = DateTime.now().difference(_sessionStart);
return {
'fps': {
'current': _currentFPS,
'average': fpsAvg,
'history': List<double>.from(_fpsHistory),
},
'memory': {
'current': _currentMemory,
'average': memAvg.toDouble(),
'history': List<int>.from(_memoryHistory),
},
'signals': {
'counts': Map<String, int>.from(_signalUpdateCounts),
'durationsMs': _signalUpdateDurations.map(
(k, v) => MapEntry(k, v.inMilliseconds),
),
},
'benchmarks': Map<String, dynamic>.from(_benchmarkResults),
'session': {
'uptimeSeconds': uptime.inSeconds,
},
};
}