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
b314fa59
Commit
b314fa59
authored
Aug 10, 2016
by
John McCutchan
Committed by
GitHub
Aug 10, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add time to frame tracking to hot run (#5316)
parent
2075816d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
4 deletions
+58
-4
utils.dart
packages/flutter_tools/lib/src/base/utils.dart
+9
-0
hot.dart
packages/flutter_tools/lib/src/hot.dart
+49
-4
No files found.
packages/flutter_tools/lib/src/base/utils.dart
View file @
b314fa59
...
...
@@ -78,6 +78,15 @@ String getSizeAsMB(int bytesLength) {
return
'
${(bytesLength / (1024 * 1024)).toStringAsFixed(1)}
MB'
;
}
String
getElapsedAsSeconds
(
Duration
duration
)
{
double
seconds
=
duration
.
inMilliseconds
/
Duration
.
MILLISECONDS_PER_SECOND
;
return
'
${seconds.toStringAsFixed(2)}
seconds'
;
}
String
getElapsedAsMilliseconds
(
Duration
duration
)
{
return
'
${duration.inMilliseconds}
ms'
;
}
/// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path.
String
getDisplayPath
(
String
fullPath
)
{
...
...
packages/flutter_tools/lib/src/hot.dart
View file @
b314fa59
...
...
@@ -29,6 +29,41 @@ String getDevFSLoaderScript() {
'loader_app.dart'
));
}
class
FirstFrameTimer
{
FirstFrameTimer
(
this
.
serviceProtocol
);
void
start
()
{
stopwatch
.
reset
();
stopwatch
.
start
();
_subscription
=
serviceProtocol
.
onExtensionEvent
.
listen
(
_onExtensionEvent
);
}
/// Returns a Future which completes after the first frame event is received.
Future
<
Null
>
firstFrame
()
=>
_completer
.
future
;
void
_onExtensionEvent
(
Event
event
)
{
if
(
event
.
extensionKind
==
'Flutter.FirstFrame'
)
_stop
();
}
void
_stop
()
{
_subscription
?.
cancel
();
_subscription
=
null
;
stopwatch
.
stop
();
_completer
.
complete
(
null
);
}
Duration
get
elapsed
{
assert
(!
stopwatch
.
isRunning
);
return
stopwatch
.
elapsed
;
}
final
Observatory
serviceProtocol
;
final
Stopwatch
stopwatch
=
new
Stopwatch
();
final
Completer
<
Null
>
_completer
=
new
Completer
<
Null
>();
StreamSubscription
<
Event
>
_subscription
;
}
class
HotRunner
extends
ResidentRunner
{
HotRunner
(
Device
device
,
{
...
...
@@ -347,16 +382,21 @@ class HotRunner extends ResidentRunner {
}
Future
<
Null
>
_restartFromSources
()
async
{
FirstFrameTimer
firstFrameTimer
=
new
FirstFrameTimer
(
serviceProtocol
);
firstFrameTimer
.
start
();
if
(
_devFS
==
null
)
{
Status
restartStatus
=
logger
.
startProgress
(
'Restarting application...'
);
await
_launchFromDisk
(
_package
,
_mainPath
);
restartStatus
.
stop
(
showElapsedTime:
true
);
}
else
{
await
_updateDevFS
();
Status
restartStatus
=
logger
.
startProgress
(
'Restarting application...'
);
await
_launchFromDevFS
(
_package
,
_mainPath
);
restartStatus
.
stop
(
showElapsedTime:
true
);
}
Status
restartStatus
=
logger
.
startProgress
(
'Waiting for application to start...'
);
// Wait for the first frame to be rendered.
await
firstFrameTimer
.
firstFrame
();
restartStatus
.
stop
(
showElapsedTime:
true
);
printStatus
(
'Restart time: '
'
${getElapsedAsMilliseconds(firstFrameTimer.elapsed)}
'
);
flutterUsage
.
sendEvent
(
'hot'
,
'restart'
);
}
...
...
@@ -380,6 +420,8 @@ class HotRunner extends ResidentRunner {
Future
<
bool
>
_reloadSources
()
async
{
if
(
serviceProtocol
.
firstIsolateId
==
null
)
throw
'Application isolate not found'
;
FirstFrameTimer
firstFrameTimer
=
new
FirstFrameTimer
(
serviceProtocol
);
firstFrameTimer
.
start
();
if
(
_devFS
!=
null
)
await
_updateDevFS
();
Status
reloadStatus
=
logger
.
startProgress
(
'Performing hot reload...'
);
...
...
@@ -410,6 +452,9 @@ class HotRunner extends ResidentRunner {
return
false
;
}
reassembleStatus
.
stop
(
showElapsedTime:
true
);
await
firstFrameTimer
.
firstFrame
();
printStatus
(
'Hot reload time: '
'
${getElapsedAsMilliseconds(firstFrameTimer.elapsed)}
'
);
return
true
;
}
...
...
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