Unverified Commit 54d75a51 authored by liyuqian's avatar liyuqian Committed by GitHub

Print frame begin time in summary (#50272)

parent 19e7db58
...@@ -103,6 +103,9 @@ class TimelineSummary { ...@@ -103,6 +103,9 @@ class TimelineSummary {
'frame_rasterizer_times': _extractGpuRasterizerDrawDurations() 'frame_rasterizer_times': _extractGpuRasterizerDrawDurations()
.map<int>((Duration duration) => duration.inMicroseconds) .map<int>((Duration duration) => duration.inMicroseconds)
.toList(), .toList(),
'frame_begin_times': _extractBeginTimestamps('Frame')
.map<int>((Duration duration) => duration.inMicroseconds)
.toList()
}; };
} }
...@@ -142,10 +145,10 @@ class TimelineSummary { ...@@ -142,10 +145,10 @@ class TimelineSummary {
.toList(); .toList();
} }
/// Extracts Duration list that are reported as a pair of begin/end events. List<Duration> _extractDurations(
/// String name,
/// See: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU Duration extractor(TimelineEvent beginEvent, TimelineEvent endEvent),
List<Duration> _extractBeginEndEvents(String name) { ) {
final List<Duration> result = <Duration>[]; final List<Duration> result = <Duration>[];
// Timeline does not guarantee that the first event is the "begin" event. // Timeline does not guarantee that the first event is the "begin" event.
...@@ -155,13 +158,40 @@ class TimelineSummary { ...@@ -155,13 +158,40 @@ class TimelineSummary {
final TimelineEvent beginEvent = events.current; final TimelineEvent beginEvent = events.current;
if (events.moveNext()) { if (events.moveNext()) {
final TimelineEvent endEvent = events.current; final TimelineEvent endEvent = events.current;
result.add(Duration(microseconds: endEvent.timestampMicros - beginEvent.timestampMicros)); result.add(extractor(beginEvent, endEvent));
} }
} }
return result; return result;
} }
/// Extracts Duration list that are reported as a pair of begin/end events.
///
/// See: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU
List<Duration> _extractBeginEndEvents(String name) {
return _extractDurations(
name,
(TimelineEvent beginEvent, TimelineEvent endEvent) {
return Duration(microseconds: endEvent.timestampMicros - beginEvent.timestampMicros);
},
);
}
List<Duration> _extractBeginTimestamps(String name) {
final List<Duration> result = _extractDurations(
name,
(TimelineEvent beginEvent, TimelineEvent endEvent) {
return Duration(microseconds: beginEvent.timestampMicros);
},
);
// Align timestamps so the first event is at 0.
for (int i = result.length - 1; i >= 0; i -= 1) {
result[i] = result[i] - result[0];
}
return result;
}
double _averageInMillis(Iterable<Duration> durations) { double _averageInMillis(Iterable<Duration> durations) {
if (durations.isEmpty) if (durations.isEmpty)
throw ArgumentError('durations is empty!'); throw ArgumentError('durations is empty!');
......
...@@ -330,6 +330,7 @@ void main() { ...@@ -330,6 +330,7 @@ void main() {
'frame_count': 3, 'frame_count': 3,
'frame_build_times': <int>[17000, 9000, 19000], 'frame_build_times': <int>[17000, 9000, 19000],
'frame_rasterizer_times': <int>[18000, 10000, 20000], 'frame_rasterizer_times': <int>[18000, 10000, 20000],
'frame_begin_times': <int>[0, 18000, 28000],
}, },
); );
}); });
...@@ -382,6 +383,7 @@ void main() { ...@@ -382,6 +383,7 @@ void main() {
'frame_count': 3, 'frame_count': 3,
'frame_build_times': <int>[17000, 9000, 19000], 'frame_build_times': <int>[17000, 9000, 19000],
'frame_rasterizer_times': <int>[18000, 10000, 20000], 'frame_rasterizer_times': <int>[18000, 10000, 20000],
'frame_begin_times': <int>[0, 18000, 28000],
}); });
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment