Commit ac1546c7 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Add hotReloadInitialDevFSSyncMilliseconds to track how long user have… (#12417)

* Add hotReloadInitialDevFSSyncMilliseconds to track how long user have to wait before being able to do first reload.

This stat is significantly different between existing and preview-dart-2 setting (for the latter, this stat is ~3x slower: 13s vs ~4s).

* Remove ws

* Cleanup timer-related code
parent 8d41fa78
...@@ -28,6 +28,7 @@ TaskFunction createHotModeTest({ bool isPreviewDart2: false }) { ...@@ -28,6 +28,7 @@ TaskFunction createHotModeTest({ bool isPreviewDart2: false }) {
}); });
return new TaskResult.successFromFile(benchmarkFile, return new TaskResult.successFromFile(benchmarkFile,
benchmarkScoreKeys: <String>[ benchmarkScoreKeys: <String>[
'hotReloadInitialDevFSSyncMilliseconds',
'hotReloadMillisecondsToFrame', 'hotReloadMillisecondsToFrame',
'hotRestartMillisecondsToFrame', 'hotRestartMillisecondsToFrame',
'hotReloadDevFSSyncMilliseconds', 'hotReloadDevFSSyncMilliseconds',
......
...@@ -128,10 +128,12 @@ class HotRunner extends ResidentRunner { ...@@ -128,10 +128,12 @@ class HotRunner extends ResidentRunner {
printError('Error initializing DevFS: $error'); printError('Error initializing DevFS: $error');
return 3; return 3;
} }
final Stopwatch initialUpdateDevFSsTimer = new Stopwatch()..start();
final bool devfsResult = await _updateDevFS(); final bool devfsResult = await _updateDevFS();
if (!devfsResult) { benchmarkData['hotReloadInitialDevFSSyncMilliseconds'] =
initialUpdateDevFSsTimer.elapsed.inMilliseconds;
if (!devfsResult)
return 3; return 3;
}
await refreshViews(); await refreshViews();
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
...@@ -331,8 +333,7 @@ class HotRunner extends ResidentRunner { ...@@ -331,8 +333,7 @@ class HotRunner extends ResidentRunner {
await refreshViews(); await refreshViews();
} }
final Stopwatch restartTimer = new Stopwatch(); final Stopwatch restartTimer = new Stopwatch()..start();
restartTimer.start();
final bool updatedDevFS = await _updateDevFS(); final bool updatedDevFS = await _updateDevFS();
if (!updatedDevFS) if (!updatedDevFS)
return new OperationResult(1, 'DevFS synchronization failed'); return new OperationResult(1, 'DevFS synchronization failed');
...@@ -362,10 +363,8 @@ class HotRunner extends ResidentRunner { ...@@ -362,10 +363,8 @@ class HotRunner extends ResidentRunner {
'${getElapsedAsMilliseconds(restartTimer.elapsed)}.'); '${getElapsedAsMilliseconds(restartTimer.elapsed)}.');
// We are now running from sources. // We are now running from sources.
_runningFromSnapshot = false; _runningFromSnapshot = false;
if (benchmarkMode) { benchmarkData['hotRestartMillisecondsToFrame'] =
benchmarkData['hotRestartMillisecondsToFrame'] = restartTimer.elapsed.inMilliseconds;
restartTimer.elapsed.inMilliseconds;
}
flutterUsage.sendEvent('hot', 'restart'); flutterUsage.sendEvent('hot', 'restart');
flutterUsage.sendTiming('hot', 'restart', restartTimer.elapsed); flutterUsage.sendTiming('hot', 'restart', restartTimer.elapsed);
return OperationResult.ok; return OperationResult.ok;
...@@ -454,36 +453,23 @@ class HotRunner extends ResidentRunner { ...@@ -454,36 +453,23 @@ class HotRunner extends ResidentRunner {
// not be affected, so we resume reporting reload times on the second // not be affected, so we resume reporting reload times on the second
// reload. // reload.
final bool shouldReportReloadTime = !_runningFromSnapshot; final bool shouldReportReloadTime = !_runningFromSnapshot;
final Stopwatch reloadTimer = new Stopwatch(); final Stopwatch reloadTimer = new Stopwatch()..start();
reloadTimer.start();
Stopwatch devFSTimer; final Stopwatch devFSTimer = new Stopwatch()..start();
Stopwatch vmReloadTimer;
Stopwatch reassembleTimer;
if (benchmarkMode) {
devFSTimer = new Stopwatch();
devFSTimer.start();
vmReloadTimer = new Stopwatch();
reassembleTimer = new Stopwatch();
}
final bool updatedDevFS = await _updateDevFS(); final bool updatedDevFS = await _updateDevFS();
// Record time it took to synchronize to DevFS.
benchmarkData['hotReloadDevFSSyncMilliseconds'] =
devFSTimer.elapsed.inMilliseconds;
if (!updatedDevFS) if (!updatedDevFS)
return new OperationResult(1, 'DevFS synchronization failed'); return new OperationResult(1, 'DevFS synchronization failed');
if (benchmarkMode) {
devFSTimer.stop();
// Record time it took to synchronize to DevFS.
benchmarkData['hotReloadDevFSSyncMilliseconds'] =
devFSTimer.elapsed.inMilliseconds;
}
if (!updatedDevFS)
return new OperationResult(1, 'Dart source error');
String reloadMessage; String reloadMessage;
final Stopwatch vmReloadTimer = new Stopwatch()..start();
try { try {
final String entryPath = fs.path.relative( final String entryPath = fs.path.relative(
previewDart2 ? mainPath + '.dill' : mainPath, previewDart2 ? mainPath + '.dill' : mainPath,
from: projectRootPath from: projectRootPath
); );
if (benchmarkMode)
vmReloadTimer.start();
final Completer<Map<String, dynamic>> retrieveFirstReloadReport = new Completer<Map<String, dynamic>>(); final Completer<Map<String, dynamic>> retrieveFirstReloadReport = new Completer<Map<String, dynamic>>();
int countExpectedReports = 0; int countExpectedReports = 0;
...@@ -540,14 +526,10 @@ class HotRunner extends ResidentRunner { ...@@ -540,14 +526,10 @@ class HotRunner extends ResidentRunner {
printError('Hot reload failed:\ncode = $errorCode\nmessage = $errorMessage\n$st'); printError('Hot reload failed:\ncode = $errorCode\nmessage = $errorMessage\n$st');
return new OperationResult(errorCode, errorMessage); return new OperationResult(errorCode, errorMessage);
} }
if (benchmarkMode) { // Record time it took for the VM to reload the sources.
// Record time it took for the VM to reload the sources. benchmarkData['hotReloadVMReloadMilliseconds'] =
vmReloadTimer.stop(); vmReloadTimer.elapsed.inMilliseconds;
benchmarkData['hotReloadVMReloadMilliseconds'] = final Stopwatch reassembleTimer = new Stopwatch()..start();
vmReloadTimer.elapsed.inMilliseconds;
}
if (benchmarkMode)
reassembleTimer.start();
// Reload the isolate. // Reload the isolate.
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
printTrace('Sending reload events to ${device.device.name}'); printTrace('Sending reload events to ${device.device.name}');
...@@ -602,19 +584,16 @@ class HotRunner extends ResidentRunner { ...@@ -602,19 +584,16 @@ class HotRunner extends ResidentRunner {
printError('Scheduling a frame for ${view.uiIsolate.name} failed: $error'); printError('Scheduling a frame for ${view.uiIsolate.name} failed: $error');
} }
} }
// Record time it took for Flutter to reassemble the application.
benchmarkData['hotReloadFlutterReassembleMilliseconds'] =
reassembleTimer.elapsed.inMilliseconds;
reloadTimer.stop(); reloadTimer.stop();
printTrace('Hot reload performed in ' printTrace('Hot reload performed in '
'${getElapsedAsMilliseconds(reloadTimer.elapsed)}.'); '${getElapsedAsMilliseconds(reloadTimer.elapsed)}.');
// Record complete time it took for the reload.
if (benchmarkMode) { benchmarkData['hotReloadMillisecondsToFrame'] =
// Record time it took for Flutter to reassemble the application. reloadTimer.elapsed.inMilliseconds;
reassembleTimer.stop();
benchmarkData['hotReloadFlutterReassembleMilliseconds'] =
reassembleTimer.elapsed.inMilliseconds;
// Record complete time it took for the reload.
benchmarkData['hotReloadMillisecondsToFrame'] =
reloadTimer.elapsed.inMilliseconds;
}
// Only report timings if we reloaded a single view without any // Only report timings if we reloaded a single view without any
// errors or timeouts. // errors or timeouts.
if ((reassembleViews.length == 1) && if ((reassembleViews.length == 1) &&
......
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