Extra timing on hot reload (#104242)
This PR adds extra timings for a hot reload. As an example, before a user might see > Performing hot reload... > Reloaded 1 of 788 libraries in 554ms. With this PR it would instead be something like > Performing hot reload... > Reloaded 1 of 788 libraries in 554ms (compile: 33 ms, reload: 153 ms, reassemble: 310 ms).
This commit is contained in:
@@ -846,6 +846,95 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(isSingleWidgetReloadEnabled: true),
|
||||
}));
|
||||
|
||||
testUsingContext('ResidentRunner reports hot reload time details', () => testbed.run(() async {
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
|
||||
listViews,
|
||||
FakeVmServiceRequest(
|
||||
method: 'getVM',
|
||||
jsonResponse: fakeVM.toJson(),
|
||||
),
|
||||
listViews,
|
||||
listViews,
|
||||
FakeVmServiceRequest(
|
||||
method: 'getVM',
|
||||
jsonResponse: fakeVM.toJson(),
|
||||
),
|
||||
const FakeVmServiceRequest(
|
||||
method: 'reloadSources',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
'pause': false,
|
||||
'rootLibUri': 'main.dart.incremental.dill',
|
||||
},
|
||||
jsonResponse: <String, Object>{
|
||||
'type': 'ReloadReport',
|
||||
'success': true,
|
||||
'details': <String, Object>{
|
||||
'loadedLibraryCount': 1,
|
||||
'finalLibraryCount': 42,
|
||||
},
|
||||
},
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'getIsolate',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
},
|
||||
jsonResponse: fakeUnpausedIsolate.toJson(),
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'ext.flutter.fastReassemble',
|
||||
args: <String, Object>{
|
||||
'isolateId': fakeUnpausedIsolate.id,
|
||||
'className': 'FOO',
|
||||
},
|
||||
),
|
||||
]);
|
||||
final FakeDelegateFlutterDevice flutterDevice = FakeDelegateFlutterDevice(
|
||||
device,
|
||||
BuildInfo.debug,
|
||||
FakeResidentCompiler(),
|
||||
devFS,
|
||||
)..vmService = fakeVmServiceHost.vmService;
|
||||
residentRunner = HotRunner(
|
||||
<FlutterDevice>[
|
||||
flutterDevice,
|
||||
],
|
||||
stayResident: false,
|
||||
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
|
||||
target: 'main.dart',
|
||||
devtoolsHandler: createNoOpHandler,
|
||||
);
|
||||
devFS.nextUpdateReport = UpdateFSReport(
|
||||
success: true,
|
||||
fastReassembleClassName: 'FOO',
|
||||
invalidatedSourcesCount: 1,
|
||||
);
|
||||
|
||||
final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync();
|
||||
final Completer<void> futureAppStart = Completer<void>.sync();
|
||||
unawaited(residentRunner.attach(
|
||||
appStartedCompleter: futureAppStart,
|
||||
connectionInfoCompleter: futureConnectionInfo,
|
||||
enableDevTools: true,
|
||||
));
|
||||
|
||||
await futureAppStart.future;
|
||||
await residentRunner.restart();
|
||||
|
||||
// The actual test: Expect to have compile, reload and reassemble times.
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
contains(RegExp(r'Reloaded 1 of 42 libraries in \d+ms '
|
||||
r'\(compile: \d+ ms, reload: \d+ ms, reassemble: \d+ ms\)\.')));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
Platform: () => FakePlatform(),
|
||||
ProjectFileInvalidator: () => FakeProjectFileInvalidator(),
|
||||
Usage: () => TestUsage(),
|
||||
FeatureFlags: () => TestFeatureFlags(isSingleWidgetReloadEnabled: true),
|
||||
}));
|
||||
|
||||
testUsingContext('ResidentRunner can send target platform to analytics from full restart', () => testbed.run(() async {
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
|
||||
listViews,
|
||||
|
||||
@@ -375,7 +375,7 @@ void main() {
|
||||
return null;
|
||||
}),
|
||||
Barrier('Performing hot reload...'.padRight(progressMessageWidth), logging: true),
|
||||
Multiple(<Pattern>[RegExp(r'^Reloaded 0 libraries in [0-9]+ms\.$'), 'called reassemble', 'called paint'], handler: (String line) {
|
||||
Multiple(<Pattern>[RegExp(r'^Reloaded 0 libraries in [0-9]+ms \(compile: \d+ ms, reload: \d+ ms, reassemble: \d+ ms\)\.$'), 'called reassemble', 'called paint'], handler: (String line) {
|
||||
processManager.killPid(pid, ProcessSignal.sigusr2);
|
||||
return null;
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user