Track the worst frame in perf tests (#3642)
* Track the worst frame in perf tests * Use backticks in "/// Returns `null` if"
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert' show JSON, JsonEncoder;
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
@@ -26,6 +27,8 @@ class TimelineSummary {
|
||||
|
||||
/// Average amount of time spent per frame in the framework building widgets,
|
||||
/// updating layout, painting and compositing.
|
||||
///
|
||||
/// Returns `null` if no frames were recorded.
|
||||
double computeAverageFrameBuildTimeMillis() {
|
||||
int totalBuildTimeMicros = 0;
|
||||
int frameCount = 0;
|
||||
@@ -40,6 +43,24 @@ class TimelineSummary {
|
||||
: null;
|
||||
}
|
||||
|
||||
/// Find amount of time spent in the framework building widgets,
|
||||
/// updating layout, painting and compositing on worst frame.
|
||||
///
|
||||
/// Returns `null` if no frames were recorded.
|
||||
double computeWorstFrameBuildTimeMillis() {
|
||||
int maxBuildTimeMicros = 0;
|
||||
int frameCount = 0;
|
||||
|
||||
for (TimedEvent event in _extractBeginFrameEvents()) {
|
||||
frameCount++;
|
||||
maxBuildTimeMicros = math.max(maxBuildTimeMicros, event.duration.inMicroseconds);
|
||||
}
|
||||
|
||||
return frameCount > 0
|
||||
? maxBuildTimeMicros / 1000
|
||||
: null;
|
||||
}
|
||||
|
||||
/// The total number of frames recorded in the timeline.
|
||||
int countFrames() => _extractBeginFrameEvents().length;
|
||||
|
||||
@@ -55,6 +76,7 @@ class TimelineSummary {
|
||||
Map<String, dynamic> get summaryJson {
|
||||
return <String, dynamic> {
|
||||
'average_frame_build_time_millis': computeAverageFrameBuildTimeMillis(),
|
||||
'worst_frame_build_time_millis': computeWorstFrameBuildTimeMillis(),
|
||||
'missed_frame_build_budget_count': computeMissedFrameBuildBudgetCount(),
|
||||
'frame_count': countFrames(),
|
||||
'frame_build_times': _extractBeginFrameEvents()
|
||||
|
||||
Reference in New Issue
Block a user