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
057a25cd
Unverified
Commit
057a25cd
authored
Apr 27, 2020
by
Kaushik Iska
Committed by
GitHub
Apr 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[timeline] Sort timeline events before summarizing (#55771)
parent
958ab933
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
12 deletions
+83
-12
timeline.dart
packages/flutter_driver/lib/src/driver/timeline.dart
+27
-10
timeline_test.dart
...ges/flutter_driver/test/src/real_tests/timeline_test.dart
+56
-2
No files found.
packages/flutter_driver/lib/src/driver/timeline.dart
View file @
057a25cd
...
...
@@ -34,12 +34,8 @@ class TimelineEvent {
json
[
'ph'
]
as
String
,
json
[
'pid'
]
as
int
,
json
[
'tid'
]
as
int
,
json
[
'dur'
]
!=
null
?
Duration
(
microseconds:
json
[
'dur'
]
as
int
)
:
null
,
json
[
'tdur'
]
!=
null
?
Duration
(
microseconds:
json
[
'tdur'
]
as
int
)
:
null
,
json
[
'dur'
]
!=
null
?
Duration
(
microseconds:
json
[
'dur'
]
as
int
)
:
null
,
json
[
'tdur'
]
!=
null
?
Duration
(
microseconds:
json
[
'tdur'
]
as
int
)
:
null
,
json
[
'ts'
]
as
int
,
json
[
'tts'
]
as
int
,
json
[
'args'
]
as
Map
<
String
,
dynamic
>,
...
...
@@ -124,11 +120,32 @@ class TimelineEvent {
List
<
TimelineEvent
>
_parseEvents
(
Map
<
String
,
dynamic
>
json
)
{
final
List
<
dynamic
>
jsonEvents
=
json
[
'traceEvents'
]
as
List
<
dynamic
>;
if
(
jsonEvents
==
null
)
if
(
jsonEvents
==
null
)
{
return
null
;
}
// TODO(vegorov): use instance method version of castFrom when it is available.
return
Iterable
.
castFrom
<
dynamic
,
Map
<
String
,
dynamic
>>(
jsonEvents
)
.
map
<
TimelineEvent
>((
Map
<
String
,
dynamic
>
eventJson
)
=>
TimelineEvent
(
eventJson
))
.
toList
();
final
List
<
TimelineEvent
>
timelineEvents
=
Iterable
.
castFrom
<
dynamic
,
Map
<
String
,
dynamic
>>(
jsonEvents
)
.
map
<
TimelineEvent
>(
(
Map
<
String
,
dynamic
>
eventJson
)
=>
TimelineEvent
(
eventJson
))
.
toList
();
timelineEvents
.
sort
((
TimelineEvent
e1
,
TimelineEvent
e2
)
{
final
int
ts1
=
e1
.
timestampMicros
;
final
int
ts2
=
e2
.
timestampMicros
;
if
(
ts1
==
null
)
{
if
(
ts2
==
null
)
{
return
0
;
}
else
{
return
-
1
;
}
}
else
if
(
ts2
==
null
)
{
return
1
;
}
else
{
return
ts1
.
compareTo
(
ts2
);
}
});
return
timelineEvents
;
}
packages/flutter_driver/test/src/real_tests/timeline_test.dart
View file @
057a25cd
...
...
@@ -32,7 +32,7 @@ void main() {
expect
(
timeline
.
events
,
hasLength
(
2
));
final
TimelineEvent
e1
=
timeline
.
events
[
0
];
final
TimelineEvent
e1
=
timeline
.
events
[
1
];
expect
(
e1
.
name
,
'test event'
);
expect
(
e1
.
category
,
'test category'
);
expect
(
e1
.
phase
,
'B'
);
...
...
@@ -44,7 +44,7 @@ void main() {
expect
(
e1
.
threadTimestampMicros
,
567
);
expect
(
e1
.
arguments
,
<
String
,
dynamic
>{
'arg1'
:
true
});
final
TimelineEvent
e2
=
timeline
.
events
[
1
];
final
TimelineEvent
e2
=
timeline
.
events
[
0
];
expect
(
e2
.
name
,
isNull
);
expect
(
e2
.
category
,
isNull
);
expect
(
e2
.
phase
,
isNull
);
...
...
@@ -56,5 +56,59 @@ void main() {
expect
(
e2
.
threadTimestampMicros
,
isNull
);
expect
(
e2
.
arguments
,
isNull
);
});
test
(
'sorts JSON'
,
()
{
final
Timeline
timeline
=
Timeline
.
fromJson
(<
String
,
dynamic
>{
'traceEvents'
:
<
Map
<
String
,
dynamic
>>[
<
String
,
dynamic
>{
'name'
:
'test event 1'
,
'ts'
:
457
,
},
<
String
,
dynamic
>{
'name'
:
'test event 2'
,
'ts'
:
456
,
},
],
});
expect
(
timeline
.
events
,
hasLength
(
2
));
expect
(
timeline
.
events
[
0
].
timestampMicros
,
equals
(
456
));
expect
(
timeline
.
events
[
1
].
timestampMicros
,
equals
(
457
));
expect
(
timeline
.
events
[
0
].
name
,
equals
(
'test event 2'
));
expect
(
timeline
.
events
[
1
].
name
,
equals
(
'test event 1'
));
});
test
(
'sorts JSON nulls first'
,
()
{
final
Timeline
timeline
=
Timeline
.
fromJson
(<
String
,
dynamic
>{
'traceEvents'
:
<
Map
<
String
,
dynamic
>>[
<
String
,
dynamic
>{
'name'
:
'test event 0'
,
'ts'
:
null
,
},
<
String
,
dynamic
>{
'name'
:
'test event 1'
,
'ts'
:
457
,
},
<
String
,
dynamic
>{
'name'
:
'test event 2'
,
'ts'
:
456
,
},
<
String
,
dynamic
>{
'name'
:
'test event 3'
,
'ts'
:
null
,
},
],
});
expect
(
timeline
.
events
,
hasLength
(
4
));
expect
(
timeline
.
events
[
0
].
timestampMicros
,
isNull
);
expect
(
timeline
.
events
[
1
].
timestampMicros
,
isNull
);
expect
(
timeline
.
events
[
2
].
timestampMicros
,
equals
(
456
));
expect
(
timeline
.
events
[
3
].
timestampMicros
,
equals
(
457
));
expect
(
timeline
.
events
[
0
].
name
,
equals
(
'test event 0'
));
expect
(
timeline
.
events
[
1
].
name
,
equals
(
'test event 3'
));
expect
(
timeline
.
events
[
2
].
name
,
equals
(
'test event 2'
));
expect
(
timeline
.
events
[
3
].
name
,
equals
(
'test event 1'
));
});
});
}
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