Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
bc0d35c3
Unverified
Commit
bc0d35c3
authored
Dec 27, 2019
by
Francisco Magdaleno
Committed by
GitHub
Dec 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland "fix duration event of timeline summary (#47742)" (#47889)
This reverts commit
50d42122
.
parent
50d42122
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
54 deletions
+78
-54
timeline_summary.dart
packages/flutter_driver/lib/src/driver/timeline_summary.dart
+13
-34
timeline_summary_test.dart
packages/flutter_driver/test/src/timeline_summary_test.dart
+65
-20
No files found.
packages/flutter_driver/lib/src/driver/timeline_summary.dart
View file @
bc0d35c3
...
...
@@ -57,27 +57,27 @@ class TimelineSummary {
///
/// Returns null if no frames were recorded.
double
computeAverageFrameRasterizerTimeMillis
()
{
return
_averageInMillis
(
_extract
Duration
(
_extractGpuRasterizerDrawEvents
()
));
return
_averageInMillis
(
_extract
GpuRasterizerDrawDurations
(
));
}
/// The longest frame rasterization time in milliseconds.
///
/// Returns null if no frames were recorded.
double
computeWorstFrameRasterizerTimeMillis
()
{
return
_maxInMillis
(
_extract
Duration
(
_extractGpuRasterizerDrawEvents
()
));
return
_maxInMillis
(
_extract
GpuRasterizerDrawDurations
(
));
}
/// The [p]-th percentile frame rasterization time in milliseconds.
///
/// Returns null if no frames were recorded.
double
computePercentileFrameRasterizerTimeMillis
(
double
p
)
{
return
_percentileInMillis
(
_extract
Duration
(
_extractGpuRasterizerDrawEvents
()
),
p
);
return
_percentileInMillis
(
_extract
GpuRasterizerDrawDurations
(
),
p
);
}
/// The number of frames that missed the [kBuildBudget] on the GPU and
/// therefore are in the danger of missing frames.
int
computeMissedFrameRasterizerBudgetCount
([
Duration
frameBuildBudget
=
kBuildBudget
])
=>
_extractGpuRasterizerDraw
Event
s
()
.
where
((
TimedEvent
event
)
=>
event
.
duration
>
kBuildBudget
)
int
computeMissedFrameRasterizerBudgetCount
([
Duration
frameBuildBudget
=
kBuildBudget
])
=>
_extractGpuRasterizerDraw
Duration
s
()
.
where
((
Duration
duration
)
=>
duration
>
kBuildBudget
)
.
length
;
/// The total number of frames recorded in the timeline.
...
...
@@ -100,8 +100,8 @@ class TimelineSummary {
'frame_build_times'
:
_extractFrameDurations
()
.
map
<
int
>((
Duration
duration
)
=>
duration
.
inMicroseconds
)
.
toList
(),
'frame_rasterizer_times'
:
_extractGpuRasterizerDraw
Event
s
()
.
map
<
int
>((
TimedEvent
event
)
=>
event
.
duration
.
inMicroseconds
)
'frame_rasterizer_times'
:
_extractGpuRasterizerDraw
Duration
s
()
.
map
<
int
>((
Duration
duration
)
=>
duration
.
inMicroseconds
)
.
toList
(),
};
}
...
...
@@ -142,15 +142,11 @@ class TimelineSummary {
.
toList
();
}
List
<
Duration
>
_extractDurations
(
String
name
)
{
return
_extractNamedEvents
(
name
).
map
<
Duration
>((
TimelineEvent
event
)
=>
event
.
duration
).
toList
();
}
/// Extracts timed events that are reported as a pair of begin/end events.
/// Extracts Duration list that are reported as a pair of begin/end events.
///
/// See: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU
List
<
TimedEvent
>
_extractBeginEndEvents
(
String
name
)
{
final
List
<
TimedEvent
>
result
=
<
TimedEvent
>[];
List
<
Duration
>
_extractBeginEndEvents
(
String
name
)
{
final
List
<
Duration
>
result
=
<
Duration
>[];
// Timeline does not guarantee that the first event is the "begin" event.
final
Iterator
<
TimelineEvent
>
events
=
_extractNamedEvents
(
name
)
...
...
@@ -159,10 +155,7 @@ class TimelineSummary {
final
TimelineEvent
beginEvent
=
events
.
current
;
if
(
events
.
moveNext
())
{
final
TimelineEvent
endEvent
=
events
.
current
;
result
.
add
(
TimedEvent
(
beginEvent
.
timestampMicros
,
endEvent
.
timestampMicros
,
));
result
.
add
(
Duration
(
microseconds:
endEvent
.
timestampMicros
-
beginEvent
.
timestampMicros
));
}
}
...
...
@@ -194,21 +187,7 @@ class TimelineSummary {
.
reduce
(
math
.
max
);
}
List
<
TimedEvent
>
_extractGpuRasterizerDrawEvents
()
=>
_extractBeginEndEvents
(
'GPURasterizer::Draw'
);
List
<
Duration
>
_extractFrameDurations
()
=>
_extractDurations
(
'Frame'
);
Iterable
<
Duration
>
_extractDuration
(
Iterable
<
TimedEvent
>
events
)
{
return
events
.
map
<
Duration
>((
TimedEvent
e
)
=>
e
.
duration
);
}
}
/// Timing information about an event that happened in the event loop.
class
TimedEvent
{
/// Creates a timed event given begin and end timestamps in microseconds.
TimedEvent
(
int
beginTimeMicros
,
int
endTimeMicros
)
:
duration
=
Duration
(
microseconds:
endTimeMicros
-
beginTimeMicros
);
List
<
Duration
>
_extractGpuRasterizerDrawDurations
()
=>
_extractBeginEndEvents
(
'GPURasterizer::Draw'
);
/// The duration of the event.
final
Duration
duration
;
List
<
Duration
>
_extractFrameDurations
()
=>
_extractBeginEndEvents
(
'Frame'
);
}
packages/flutter_driver/test/src/timeline_summary_test.dart
View file @
bc0d35c3
...
...
@@ -20,11 +20,16 @@ void main() {
}));
}
Map
<
String
,
dynamic
>
build
(
int
timeStamp
,
int
duration
)
=>
<
String
,
dynamic
>{
Map
<
String
,
dynamic
>
frameBegin
(
int
timeStamp
)
=>
<
String
,
dynamic
>{
'name'
:
'Frame'
,
'ph'
:
'X'
,
'ph'
:
'B'
,
'ts'
:
timeStamp
,
};
Map
<
String
,
dynamic
>
frameEnd
(
int
timeStamp
)
=>
<
String
,
dynamic
>{
'name'
:
'Frame'
,
'ph'
:
'E'
,
'ts'
:
timeStamp
,
'dur'
:
duration
,
};
Map
<
String
,
dynamic
>
begin
(
int
timeStamp
)
=>
<
String
,
dynamic
>{
...
...
@@ -54,8 +59,8 @@ void main() {
test
(
'counts frames'
,
()
{
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
build
(
1000
,
1
000
),
build
(
3000
,
2
000
),
frameBegin
(
1000
),
frameEnd
(
2
000
),
frameBegin
(
3000
),
frameEnd
(
5
000
),
]).
countFrames
(),
2
,
);
...
...
@@ -73,12 +78,32 @@ void main() {
test
(
'computes average frame build time in milliseconds'
,
()
{
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
build
(
1000
,
1
000
),
build
(
3000
,
2
000
),
frameBegin
(
1000
),
frameEnd
(
2
000
),
frameBegin
(
3000
),
frameEnd
(
5
000
),
]).
computeAverageFrameBuildTimeMillis
(),
1.5
,
);
});
test
(
'skips leading "end" events'
,
()
{
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
frameEnd
(
1000
),
frameBegin
(
2000
),
frameEnd
(
4000
),
]).
computeAverageFrameBuildTimeMillis
(),
2.0
,
);
});
test
(
'skips trailing "begin" events'
,
()
{
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
frameBegin
(
2000
),
frameEnd
(
4000
),
frameBegin
(
5000
),
]).
computeAverageFrameBuildTimeMillis
(),
2.0
,
);
});
});
group
(
'worst_frame_build_time_millis'
,
()
{
...
...
@@ -92,15 +117,35 @@ void main() {
test
(
'computes worst frame build time in milliseconds'
,
()
{
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
build
(
1000
,
1000
),
build
(
3000
,
2000
),
frameBegin
(
1000
),
frameEnd
(
2000
),
frameBegin
(
3000
),
frameEnd
(
5000
),
]).
computeWorstFrameBuildTimeMillis
(),
2.0
,
);
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
frameBegin
(
3000
),
frameEnd
(
5000
),
frameBegin
(
1000
),
frameEnd
(
2000
),
]).
computeWorstFrameBuildTimeMillis
(),
2.0
,
);
});
test
(
'skips leading "end" events'
,
()
{
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
frameEnd
(
1000
),
frameBegin
(
2000
),
frameEnd
(
4000
),
]).
computeWorstFrameBuildTimeMillis
(),
2.0
,
);
});
test
(
'skips trailing "begin" events'
,
()
{
expect
(
summarize
(<
Map
<
String
,
dynamic
>>[
build
(
3000
,
2
000
),
build
(
1000
,
1
000
),
frameBegin
(
2000
),
frameEnd
(
4
000
),
frameBegin
(
5
000
),
]).
computeWorstFrameBuildTimeMillis
(),
2.0
,
);
...
...
@@ -110,9 +155,9 @@ void main() {
group
(
'computeMissedFrameBuildBudgetCount'
,
()
{
test
(
'computes the number of missed build budgets'
,
()
{
final
TimelineSummary
summary
=
summarize
(<
Map
<
String
,
dynamic
>>[
build
(
1000
,
17
000
),
build
(
19000
,
9
000
),
build
(
29000
,
18
000
),
frameBegin
(
1000
),
frameEnd
(
18
000
),
frameBegin
(
19000
),
frameEnd
(
28
000
),
frameBegin
(
29000
),
frameEnd
(
47
000
),
]);
expect
(
summary
.
countFrames
(),
3
);
...
...
@@ -267,9 +312,9 @@ void main() {
begin
(
1000
),
end
(
19000
),
begin
(
19000
),
end
(
29000
),
begin
(
29000
),
end
(
49000
),
build
(
1000
,
17
000
),
build
(
19000
,
9
000
),
build
(
29000
,
19
000
),
frameBegin
(
1000
),
frameEnd
(
18
000
),
frameBegin
(
19000
),
frameEnd
(
28
000
),
frameBegin
(
29000
),
frameEnd
(
48
000
),
]).
summaryJson
,
<
String
,
dynamic
>{
'average_frame_build_time_millis'
:
15.0
,
...
...
@@ -317,9 +362,9 @@ void main() {
begin
(
1000
),
end
(
19000
),
begin
(
19000
),
end
(
29000
),
begin
(
29000
),
end
(
49000
),
build
(
1000
,
17
000
),
build
(
19000
,
9
000
),
build
(
29000
,
19
000
),
frameBegin
(
1000
),
frameEnd
(
18
000
),
frameBegin
(
19000
),
frameEnd
(
28
000
),
frameBegin
(
29000
),
frameEnd
(
48
000
),
]).
writeSummaryToFile
(
'test'
,
destinationDirectory:
tempDir
.
path
);
final
String
written
=
await
fs
.
file
(
path
.
join
(
tempDir
.
path
,
'test.timeline_summary.json'
)).
readAsString
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment