From 3437fd9c03f5954aed4e26fcbab7c3f1298281b9 Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Mon, 29 Aug 2022 16:12:22 -0700 Subject: [PATCH] Add initial compile tests (#109177) --- dev/devicelab/lib/tasks/perf_tests.dart | 36 ++++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 85d8368a19..351759ecec 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -1359,20 +1359,32 @@ class CompileTest { return inDirectory(testDirectory, () async { await flutter('packages', options: ['get']); - final Map compileRelease = await _compileApp(reportPackageContentSizes: reportPackageContentSizes); - final Map compileDebug = await _compileDebug( + // "initial" compile required downloading and creating the `android/.gradle` directory while "full" + // compiles only run `flutter clean` between runs. + final Map compileInitialRelease = await _compileApp(deleteGradleCache: true); + final Map compileFullRelease = await _compileApp(deleteGradleCache: false); + final Map compileInitialDebug = await _compileDebug( clean: true, + deleteGradleCache: true, + metricKey: 'debug_initial_compile_millis', + ); + final Map compileFullDebug = await _compileDebug( + clean: true, + deleteGradleCache: false, metricKey: 'debug_full_compile_millis', ); // Build again without cleaning, should be faster. final Map compileSecondDebug = await _compileDebug( clean: false, + deleteGradleCache: false, metricKey: 'debug_second_compile_millis', ); final Map metrics = { - ...compileRelease, - ...compileDebug, + ...compileInitialRelease, + ...compileFullRelease, + ...compileInitialDebug, + ...compileFullDebug, ...compileSecondDebug, }; @@ -1384,6 +1396,7 @@ class CompileTest { // Build after "edit" without clean should be faster than first build final Map compileAfterEditDebug = await _compileDebug( clean: false, + deleteGradleCache: false, metricKey: 'debug_compile_after_edit_millis', ); metrics.addAll(compileAfterEditDebug); @@ -1395,8 +1408,12 @@ class CompileTest { }); } - static Future> _compileApp({ bool reportPackageContentSizes = false }) async { + Future> _compileApp({required bool deleteGradleCache}) async { await flutter('clean'); + if (deleteGradleCache) { + final Directory gradleCacheDir = Directory('$testDirectory/android/.gradle'); + gradleCacheDir.deleteSync(recursive: true); + } final Stopwatch watch = Stopwatch(); int releaseSizeInBytes; final List options = ['--release']; @@ -1502,20 +1519,25 @@ class CompileTest { } metrics.addAll({ - 'release_full_compile_millis': watch.elapsedMilliseconds, + 'release_${deleteGradleCache ? 'initial' : 'full'}_compile_millis': watch.elapsedMilliseconds, 'release_size_bytes': releaseSizeInBytes, }); return metrics; } - static Future> _compileDebug({ + Future> _compileDebug({ + required bool deleteGradleCache, required bool clean, required String metricKey, }) async { if (clean) { await flutter('clean'); } + if (deleteGradleCache) { + final Directory gradleCacheDir = Directory('$testDirectory/android/.gradle'); + gradleCacheDir.deleteSync(recursive: true); + } final Stopwatch watch = Stopwatch(); final List options = ['--debug']; switch (deviceOperatingSystem) {