Reduce noise on the memory benchmarks (#19630)
- Check memory usage in release builds, not profile. - Use multiple runs and average the results.
This commit is contained in:
@@ -4,11 +4,16 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
import 'package:flutter_devicelab/framework/adb.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(createComplexLayoutScrollMemoryTest());
|
||||
await task(new MemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_memory/scroll_perf.dart',
|
||||
'com.yourcompany.complexLayout',
|
||||
).run);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,57 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
/// Measure application memory usage after pausing and resuming the app
|
||||
/// with the Android back button.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
import 'package:flutter_devicelab/framework/adb.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
const String packageName = 'io.flutter.demo.gallery';
|
||||
const String activityName = 'io.flutter.demo.gallery.MainActivity';
|
||||
|
||||
class BackButtonMemoryTest extends MemoryTest {
|
||||
BackButtonMemoryTest() : super('${flutterDirectory.path}/examples/flutter_gallery', 'test_memory/back_button.dart', packageName);
|
||||
|
||||
@override
|
||||
AndroidDevice get device => super.device;
|
||||
|
||||
/// Perform a series of back button suspend and resume cycles.
|
||||
@override
|
||||
Future<void> useMemory() async {
|
||||
await launchApp();
|
||||
await recordStart();
|
||||
for (int iteration = 0; iteration < 10; iteration += 1) {
|
||||
print('back/forward iteration $iteration');
|
||||
|
||||
// Push back button, wait for it to be seen by the Flutter app.
|
||||
prepareForNextMessage('AppLifecycleState.paused');
|
||||
await device.shellExec('input', <String>['keyevent', 'KEYCODE_BACK']);
|
||||
await receivedNextMessage;
|
||||
|
||||
// Give Android time to settle (e.g. run GCs) after closing the app.
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
// Relaunch the app, wait for it to launch.
|
||||
prepareForNextMessage('READY');
|
||||
final String output = await device.shellEval('am', <String>['start', '-n', '$packageName/$activityName']);
|
||||
print('adb shell am start: $output');
|
||||
if (output.contains('Error'))
|
||||
fail('unable to launch activity');
|
||||
await receivedNextMessage;
|
||||
|
||||
// Wait for the Flutter app to settle (e.g. run GCs).
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
await recordEnd();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(createGalleryBackButtonMemoryTest());
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(new BackButtonMemoryTest().run);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,14 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(createGalleryNavigationMemoryTest());
|
||||
await task(new MemoryTest(
|
||||
'${flutterDirectory.path}/examples/flutter_gallery',
|
||||
'test_memory/memory_nav.dart',
|
||||
'io.flutter.demo.gallery',
|
||||
).run);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,36 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
class HelloWorldMemoryTest extends MemoryTest {
|
||||
HelloWorldMemoryTest() : super(
|
||||
'${flutterDirectory.path}/examples/hello_world',
|
||||
'lib/main.dart',
|
||||
'io.flutter.examples.hello_world',
|
||||
);
|
||||
|
||||
/// Launch an app with no instrumentation and measure its memory usage after
|
||||
/// 1.5s and 3.0s.
|
||||
@override
|
||||
Future<void> useMemory() async {
|
||||
print('launching $project$test on device...');
|
||||
await flutter('run', options: <String>[
|
||||
'--verbose',
|
||||
'--release',
|
||||
'--no-resident',
|
||||
'-d', device.deviceId,
|
||||
test,
|
||||
]);
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 1500));
|
||||
await recordStart();
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 3000));
|
||||
await recordEnd();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(createHelloWorldMemoryTest());
|
||||
await task(new HelloWorldMemoryTest().run);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user