FrameTimingSummarizer constructor Null safety
- List<
FrameTiming> data, - {int? newGenGCCount,
- int? oldGenGCCount}
Summarize data
to frame build time and frame rasterizer time statistics.
See TimelineSummary.summaryJson for detail.
Implementation
factory FrameTimingSummarizer(
List<FrameTiming> data, {
int? newGenGCCount,
int? oldGenGCCount,
}) {
assert(data != null);
assert(data.isNotEmpty);
final List<Duration> frameBuildTime = List<Duration>.unmodifiable(
data.map<Duration>((FrameTiming datum) => datum.buildDuration),
);
final List<Duration> frameBuildTimeSorted =
List<Duration>.from(frameBuildTime)..sort();
final List<Duration> frameRasterizerTime = List<Duration>.unmodifiable(
data.map<Duration>((FrameTiming datum) => datum.rasterDuration),
);
final List<Duration> frameRasterizerTimeSorted =
List<Duration>.from(frameRasterizerTime)..sort();
final List<Duration> vsyncOverhead = List<Duration>.unmodifiable(
data.map<Duration>((FrameTiming datum) => datum.vsyncOverhead),
);
final List<int> layerCacheCounts = List<int>.unmodifiable(
data.map<int>((FrameTiming datum) => datum.layerCacheCount),
);
final List<int> layerCacheCountsSorted = List<int>.from(layerCacheCounts)..sort();
final List<int> layerCacheBytes = List<int>.unmodifiable(
data.map<int>((FrameTiming datum) => datum.layerCacheBytes),
);
final List<int> layerCacheBytesSorted = List<int>.from(layerCacheBytes)..sort();
final List<int> pictureCacheCounts = List<int>.unmodifiable(
data.map<int>((FrameTiming datum) => datum.pictureCacheCount),
);
final List<int> pictureCacheCountsSorted = List<int>.from(pictureCacheCounts)..sort();
final List<int> pictureCacheBytes = List<int>.unmodifiable(
data.map<int>((FrameTiming datum) => datum.pictureCacheBytes),
);
final List<int> pictureCacheBytesSorted = List<int>.from(pictureCacheBytes)..sort();
final List<Duration> vsyncOverheadSorted =
List<Duration>.from(vsyncOverhead)..sort();
Duration add(Duration a, Duration b) => a + b;
int addInts(int a, int b) => a + b;
return FrameTimingSummarizer._(
frameBuildTime: frameBuildTime,
frameRasterizerTime: frameRasterizerTime,
vsyncOverhead: vsyncOverhead,
// This average calculation is microsecond precision, which is fine
// because typical values of these times are milliseconds.
averageFrameBuildTime: frameBuildTime.reduce(add) ~/ data.length,
p90FrameBuildTime: _findPercentile(frameBuildTimeSorted, 0.90),
p99FrameBuildTime: _findPercentile(frameBuildTimeSorted, 0.99),
worstFrameBuildTime: frameBuildTimeSorted.last,
missedFrameBuildBudget: _countExceed(frameBuildTimeSorted, kBuildBudget),
averageFrameRasterizerTime:
frameRasterizerTime.reduce(add) ~/ data.length,
p90FrameRasterizerTime: _findPercentile(frameRasterizerTimeSorted, 0.90),
p99FrameRasterizerTime: _findPercentile(frameRasterizerTimeSorted, 0.99),
worstFrameRasterizerTime: frameRasterizerTimeSorted.last,
averageLayerCacheCount: layerCacheCounts.reduce(addInts) / data.length,
p90LayerCacheCount: _findPercentile(layerCacheCountsSorted, 0.90),
p99LayerCacheCount: _findPercentile(layerCacheCountsSorted, 0.99),
worstLayerCacheCount: layerCacheCountsSorted.last,
averageLayerCacheBytes: layerCacheBytes.reduce(addInts) / data.length,
p90LayerCacheBytes: _findPercentile(layerCacheBytesSorted, 0.90),
p99LayerCacheBytes: _findPercentile(layerCacheBytesSorted, 0.99),
worstLayerCacheBytes: layerCacheBytesSorted.last,
averagePictureCacheCount: pictureCacheCounts.reduce(addInts) / data.length,
p90PictureCacheCount: _findPercentile(pictureCacheCountsSorted, 0.90),
p99PictureCacheCount: _findPercentile(pictureCacheCountsSorted, 0.99),
worstPictureCacheCount: pictureCacheCountsSorted.last,
averagePictureCacheBytes: pictureCacheBytes.reduce(addInts) / data.length,
p90PictureCacheBytes: _findPercentile(pictureCacheBytesSorted, 0.90),
p99PictureCacheBytes: _findPercentile(pictureCacheBytesSorted, 0.99),
worstPictureCacheBytes: pictureCacheBytesSorted.last,
missedFrameRasterizerBudget:
_countExceed(frameRasterizerTimeSorted, kBuildBudget),
averageVsyncOverhead: vsyncOverhead.reduce(add) ~/ data.length,
p90VsyncOverhead: _findPercentile(vsyncOverheadSorted, 0.90),
p99VsyncOverhead: _findPercentile(vsyncOverheadSorted, 0.99),
worstVsyncOverhead: vsyncOverheadSorted.last,
newGenGCCount: newGenGCCount ?? -1,
oldGenGCCount: oldGenGCCount ?? -1,
);
}