Force GC before GC-sensitive benchmark runs (#23289)
This commit is contained in:
parent
7aeb539da9
commit
9b5c780604
@ -26,6 +26,9 @@ void main() {
|
|||||||
// benchmark has greater noise.
|
// benchmark has greater noise.
|
||||||
// See: https://github.com/flutter/flutter/issues/19434
|
// See: https://github.com/flutter/flutter/issues/19434
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 250));
|
await Future<void>.delayed(const Duration(milliseconds: 250));
|
||||||
|
|
||||||
|
await driver.forceGC();
|
||||||
|
|
||||||
final Timeline timeline = await driver.traceAction(() async {
|
final Timeline timeline = await driver.traceAction(() async {
|
||||||
// Find the scrollable stock list
|
// Find the scrollable stock list
|
||||||
final SerializableFinder list = find.byValueKey(listKey);
|
final SerializableFinder list = find.byValueKey(listKey);
|
||||||
|
@ -27,6 +27,8 @@ void main() {
|
|||||||
// Let app become fully idle.
|
// Let app become fully idle.
|
||||||
await Future<void>.delayed(const Duration(seconds: 2));
|
await Future<void>.delayed(const Duration(seconds: 2));
|
||||||
|
|
||||||
|
await driver.forceGC();
|
||||||
|
|
||||||
final Timeline timeline = await driver.traceAction(() async {
|
final Timeline timeline = await driver.traceAction(() async {
|
||||||
expect(await driver.setSemantics(true), isTrue);
|
expect(await driver.setSemantics(true), isTrue);
|
||||||
});
|
});
|
||||||
|
@ -137,6 +137,7 @@ class FlutterDriver {
|
|||||||
static const String _setVMTimelineFlagsMethodName = '_setVMTimelineFlags';
|
static const String _setVMTimelineFlagsMethodName = '_setVMTimelineFlags';
|
||||||
static const String _getVMTimelineMethodName = '_getVMTimeline';
|
static const String _getVMTimelineMethodName = '_getVMTimeline';
|
||||||
static const String _clearVMTimelineMethodName = '_clearVMTimeline';
|
static const String _clearVMTimelineMethodName = '_clearVMTimeline';
|
||||||
|
static const String _collectAllGarbageMethodName = '_collectAllGarbage';
|
||||||
|
|
||||||
static int _nextDriverId = 0;
|
static int _nextDriverId = 0;
|
||||||
|
|
||||||
@ -791,6 +792,22 @@ class FlutterDriver {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Force a garbage collection run in the VM.
|
||||||
|
Future<void> forceGC() async {
|
||||||
|
try {
|
||||||
|
await _peer
|
||||||
|
.sendRequest(_collectAllGarbageMethodName, <String, String>{
|
||||||
|
'isolateId': 'isolates/${_appIsolate.numberAsString}',
|
||||||
|
});
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
throw DriverError(
|
||||||
|
'Failed to force a GC due to remote error',
|
||||||
|
error,
|
||||||
|
stackTrace,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Closes the underlying connection to the VM service.
|
/// Closes the underlying connection to the VM service.
|
||||||
///
|
///
|
||||||
/// Returns a [Future] that fires once the connection has been closed.
|
/// Returns a [Future] that fires once the connection has been closed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user