From a152c0f429eeebe20aa3d3c85f3fe84790ed776c Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 19 Oct 2020 16:51:28 -0700 Subject: [PATCH] [devicelab] reland: reduce iterations of startup test, use application binary (#68532) These devicelab tests are incredibly flaky. Currently they will build & install the same application 15 times. This causes the temp storage to fill up on android, and has a good chance of flaking on iOS due to install issues. The change from 3 to 15 increased total test time for 2 -> 12 minutes on iOS, or roughly 5 more test equivalents for every single iOS test. Reduce the iteration count back to 5 Uninstall the app after each run so temp storage does not fill up. --- dev/devicelab/lib/tasks/perf_tests.dart | 55 ++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 3b00a813fe..cc64c7cb08 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -454,24 +454,58 @@ class StartupTest { Future run() async { return await inDirectory(testDirectory, () async { - final String deviceId = (await devices.workingDevice).deviceId; - await flutter('packages', options: ['get']); - - const int iterations = 15; + final Device device = await devices.workingDevice; + const int iterations = 5; final List> results = >[]; - for (int i = 0; i < iterations; ++i) { + + section('Building application'); + String applicationBinaryPath; + switch (deviceOperatingSystem) { + case DeviceOperatingSystem.android: + await flutter('build', options: [ + 'apk', + '-v', + '--profile', + '--target-platform=android-arm,android-arm64', + '--machine', + ]); + applicationBinaryPath = '$testDirectory/build/app/outputs/flutter-apk/app-profile.apk'; + break; + case DeviceOperatingSystem.ios: + await flutter('build', options: [ + 'ios', + '-v', + '--profile', + '--machine', + ]); + applicationBinaryPath = _findIosAppInBuildDirectory('$testDirectory/build/ios/iphoneos'); + break; + case DeviceOperatingSystem.fuchsia: + case DeviceOperatingSystem.fake: + break; + } + + for (int i = 0; i < iterations; i += 1) { await flutter('run', options: [ '--no-android-gradle-daemon', '--verbose', '--profile', '--trace-startup', '-d', - deviceId, + device.deviceId, + if (applicationBinaryPath != null) + '--use-application-binary=$applicationBinaryPath', ]); final Map data = json.decode( file('$testDirectory/build/start_up_info.json').readAsStringSync(), ) as Map; results.add(data); + + await flutter('install', options: [ + '--uninstall-only', + '-d', + device.deviceId, + ]); } final Map averageResults = _average(results, iterations); @@ -1428,3 +1462,12 @@ class _UnzipListEntry { final int compressedSize; final String path; } + +String _findIosAppInBuildDirectory(String searchDirectory) { + for (final FileSystemEntity entity in Directory(searchDirectory).listSync()) { + if (entity.path.endsWith('.app')) { + return entity.path; + } + } + return null; +}