This reverts commit 2175e64e4f.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
@@ -16,9 +18,10 @@ import '../framework/utils.dart';
|
||||
abstract class BuildTestTask {
|
||||
BuildTestTask(this.args, {this.workingDirectory, this.runFlutterClean = true,}) {
|
||||
final ArgResults argResults = argParser.parse(args);
|
||||
applicationBinaryPath = argResults[kApplicationBinaryPathOption] as String?;
|
||||
applicationBinaryPath = argResults[kApplicationBinaryPathOption] as String;
|
||||
buildOnly = argResults[kBuildOnlyFlag] as bool;
|
||||
testOnly = argResults[kTestOnlyFlag] as bool;
|
||||
|
||||
}
|
||||
|
||||
static const String kApplicationBinaryPathOption = 'application-binary-path';
|
||||
@@ -45,10 +48,10 @@ abstract class BuildTestTask {
|
||||
/// Path to a built application to use in [test].
|
||||
///
|
||||
/// If not given, will default to child's expected location.
|
||||
String? applicationBinaryPath;
|
||||
String applicationBinaryPath;
|
||||
|
||||
/// Where the test artifacts are stored, such as performance results.
|
||||
final Directory? workingDirectory;
|
||||
final Directory workingDirectory;
|
||||
|
||||
/// Run Flutter build to create [applicationBinaryPath].
|
||||
Future<void> build() async {
|
||||
@@ -90,7 +93,7 @@ abstract class BuildTestTask {
|
||||
///
|
||||
/// Tasks can override to support default values. Otherwise, it will default
|
||||
/// to needing to be passed as an argument in the test runner.
|
||||
String? getApplicationBinaryPath() => applicationBinaryPath;
|
||||
String getApplicationBinaryPath() => applicationBinaryPath;
|
||||
|
||||
/// Run this task.
|
||||
///
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
@@ -13,8 +15,8 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
TaskFunction dartPluginRegistryTest({
|
||||
String? deviceIdOverride,
|
||||
Map<String, String>? environment,
|
||||
String deviceIdOverride,
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
final Directory tempDir = Directory.systemTemp
|
||||
.createTempSync('flutter_devicelab_dart_plugin_test.');
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
@@ -53,9 +55,9 @@ class GalleryTransitionTest {
|
||||
final bool needFullTimeline;
|
||||
final String testFile;
|
||||
final String timelineSummaryFile;
|
||||
final String? timelineTraceFile;
|
||||
final String? transitionDurationFile;
|
||||
final String? driverFile;
|
||||
final String timelineTraceFile;
|
||||
final String transitionDurationFile;
|
||||
final String driverFile;
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
final Device device = await devices.workingDevice;
|
||||
@@ -63,7 +65,7 @@ class GalleryTransitionTest {
|
||||
final String deviceId = device.deviceId;
|
||||
final Directory galleryDirectory = dir('${flutterDirectory.path}/dev/integration_tests/flutter_gallery');
|
||||
await inDirectory<void>(galleryDirectory, () async {
|
||||
String? applicationBinaryPath;
|
||||
String applicationBinaryPath;
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.android) {
|
||||
section('BUILDING APPLICATION');
|
||||
await flutter(
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
@@ -18,7 +20,7 @@ final Directory flutterGalleryDir = dir(path.join(flutterDirectory.path, 'dev/in
|
||||
const String kSourceLine = 'fontSize: (orientation == Orientation.portrait) ? 32.0 : 24.0';
|
||||
const String kReplacementLine = 'fontSize: (orientation == Orientation.portrait) ? 34.0 : 24.0';
|
||||
|
||||
TaskFunction createHotModeTest({String? deviceIdOverride, Map<String, String>? environment}) {
|
||||
TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> environment}) {
|
||||
// This file is modified during the test and needs to be restored at the end.
|
||||
final File flutterFrameworkSource = file(path.join(
|
||||
flutterDirectory.path, 'packages/flutter/lib/src/widgets/framework.dart',
|
||||
@@ -33,13 +35,13 @@ TaskFunction createHotModeTest({String? deviceIdOverride, Map<String, String>? e
|
||||
final File benchmarkFile = file(path.join(_editedFlutterGalleryDir.path, 'hot_benchmark.json'));
|
||||
rm(benchmarkFile);
|
||||
final List<String> options = <String>[
|
||||
'--hot', '-d', deviceIdOverride!, '--benchmark', '--resident', '--no-android-gradle-daemon', '--no-publish-port', '--verbose',
|
||||
'--hot', '-d', deviceIdOverride, '--benchmark', '--resident', '--no-android-gradle-daemon', '--no-publish-port', '--verbose',
|
||||
];
|
||||
int hotReloadCount = 0;
|
||||
late Map<String, dynamic> smallReloadData;
|
||||
late Map<String, dynamic> mediumReloadData;
|
||||
late Map<String, dynamic> largeReloadData;
|
||||
late Map<String, dynamic> freshRestartReloadsData;
|
||||
Map<String, dynamic> smallReloadData;
|
||||
Map<String, dynamic> mediumReloadData;
|
||||
Map<String, dynamic> largeReloadData;
|
||||
Map<String, dynamic> freshRestartReloadsData;
|
||||
|
||||
|
||||
await inDirectory<void>(flutterDirectory, () async {
|
||||
@@ -215,7 +217,7 @@ TaskFunction createHotModeTest({String? deviceIdOverride, Map<String, String>? e
|
||||
|
||||
Future<Map<String, Object>> captureReloadData(
|
||||
List<String> options,
|
||||
Map<String, String>? environment,
|
||||
Map<String, String> environment,
|
||||
File benchmarkFile,
|
||||
void Function(String, Process) onLine,
|
||||
) async {
|
||||
@@ -245,7 +247,7 @@ Future<Map<String, Object>> captureReloadData(
|
||||
|
||||
await Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
|
||||
await process.exitCode;
|
||||
final Map<String, Object> result = json.decode(benchmarkFile.readAsStringSync()) as Map<String, Object>;
|
||||
final Map<String, dynamic> result = json.decode(benchmarkFile.readAsStringSync()) as Map<String, dynamic>;
|
||||
benchmarkFile.deleteSync();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import '../framework/devices.dart';
|
||||
import '../framework/framework.dart';
|
||||
import '../framework/task_result.dart';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert' show LineSplitter, json, utf8;
|
||||
import 'dart:io';
|
||||
@@ -514,7 +516,7 @@ class StartupTest {
|
||||
final List<Map<String, dynamic>> results = <Map<String, dynamic>>[];
|
||||
|
||||
section('Building application');
|
||||
String? applicationBinaryPath;
|
||||
String applicationBinaryPath;
|
||||
switch (deviceOperatingSystem) {
|
||||
case DeviceOperatingSystem.android:
|
||||
await flutter('build', options: <String>[
|
||||
@@ -584,7 +586,7 @@ class StartupTest {
|
||||
'-d',
|
||||
device.deviceId,
|
||||
'--out',
|
||||
hostAgent.dumpDirectory!
|
||||
hostAgent.dumpDirectory
|
||||
.childFile('screenshot_startup_failure_$currentFailures.png')
|
||||
.path,
|
||||
],
|
||||
@@ -628,7 +630,7 @@ class DevtoolsStartupTest {
|
||||
final Device device = await devices.workingDevice;
|
||||
|
||||
section('Building application');
|
||||
String? applicationBinaryPath;
|
||||
String applicationBinaryPath;
|
||||
switch (deviceOperatingSystem) {
|
||||
case DeviceOperatingSystem.android:
|
||||
await flutter('build', options: <String>[
|
||||
@@ -731,7 +733,7 @@ class PerfTest {
|
||||
this.needsFullTimeline = true,
|
||||
this.benchmarkScoreKeys,
|
||||
this.dartDefine = '',
|
||||
String? resultFilename,
|
||||
String resultFilename,
|
||||
}): _resultFilename = resultFilename;
|
||||
|
||||
const PerfTest.e2e(
|
||||
@@ -751,12 +753,12 @@ class PerfTest {
|
||||
/// The main entry-point file of the application, as run on the device.
|
||||
final String testTarget;
|
||||
// The prefix name of the filename such as `<timelineFileName>.timeline_summary.json`.
|
||||
final String? timelineFileName;
|
||||
final String timelineFileName;
|
||||
String get traceFilename => '$timelineFileName.timeline';
|
||||
String get resultFilename => _resultFilename ?? '$timelineFileName.timeline_summary';
|
||||
final String? _resultFilename;
|
||||
final String _resultFilename;
|
||||
/// The test file to run on the host.
|
||||
final String? testDriver;
|
||||
final String testDriver;
|
||||
/// Whether to collect CPU and GPU metrics.
|
||||
final bool measureCpuGpu;
|
||||
/// Whether to collect memory metrics.
|
||||
@@ -786,7 +788,7 @@ class PerfTest {
|
||||
/// if (measureCpuGpu) 'average_gpu_usage',
|
||||
/// ]
|
||||
/// ```
|
||||
final List<String>? benchmarkScoreKeys;
|
||||
final List<String> benchmarkScoreKeys;
|
||||
|
||||
/// Additional flags for `--dart-define` to control the test
|
||||
final String dartDefine;
|
||||
@@ -798,8 +800,8 @@ class PerfTest {
|
||||
@protected
|
||||
Future<TaskResult> internalRun({
|
||||
bool cacheSkSL = false,
|
||||
String? existingApp,
|
||||
String? writeSkslFileName,
|
||||
String existingApp,
|
||||
String writeSkslFileName,
|
||||
}) {
|
||||
return inDirectory<TaskResult>(testDirectory, () async {
|
||||
final Device device = await devices.workingDevice;
|
||||
@@ -816,7 +818,7 @@ class PerfTest {
|
||||
'--trace-startup', // Enables "endless" timeline event buffering.
|
||||
'-t', testTarget,
|
||||
if (testDriver != null)
|
||||
...<String>['--driver', testDriver!],
|
||||
...<String>['--driver', testDriver],
|
||||
if (existingApp != null)
|
||||
...<String>['--use-existing-app', existingApp],
|
||||
if (writeSkslFileName != null)
|
||||
@@ -888,9 +890,9 @@ class PerfTestWithSkSL extends PerfTest {
|
||||
String testTarget,
|
||||
String timelineFileName, {
|
||||
bool measureCpuGpu = false,
|
||||
String? testDriver,
|
||||
String testDriver,
|
||||
bool needsFullTimeline = true,
|
||||
List<String>? benchmarkScoreKeys,
|
||||
List<String> benchmarkScoreKeys,
|
||||
}) : super(
|
||||
testDirectory,
|
||||
testTarget,
|
||||
@@ -962,7 +964,7 @@ class PerfTestWithSkSL extends PerfTest {
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> _runApp({String? appBinary, bool cacheSkSL = false, String? skslPath}) async {
|
||||
Future<String> _runApp({String appBinary, bool cacheSkSL = false, String skslPath}) async {
|
||||
if (File(_vmserviceFileName).existsSync()) {
|
||||
File(_vmserviceFileName).deleteSync();
|
||||
}
|
||||
@@ -1025,9 +1027,9 @@ class PerfTestWithSkSL extends PerfTest {
|
||||
});
|
||||
}
|
||||
|
||||
late String _flutterPath;
|
||||
late Device _device;
|
||||
late Process _runProcess;
|
||||
String _flutterPath;
|
||||
Device _device;
|
||||
Process _runProcess;
|
||||
|
||||
static const String _kVmserviceOutFileName = 'vmservice.out';
|
||||
}
|
||||
@@ -1071,16 +1073,12 @@ class WebCompileTest {
|
||||
///
|
||||
/// Run a single web compile test for the app under [directory], and store
|
||||
/// its metrics with prefix [metric].
|
||||
static Future<Map<String, int>> runSingleBuildTest({
|
||||
required String directory,
|
||||
required String metric,
|
||||
bool measureBuildTime = false,
|
||||
}) {
|
||||
static Future<Map<String, int>> runSingleBuildTest({String directory, String metric, bool measureBuildTime = false}) {
|
||||
return inDirectory<Map<String, int>>(directory, () async {
|
||||
final Map<String, int> metrics = <String, int>{};
|
||||
|
||||
await flutter('packages', options: <String>['get']);
|
||||
final Stopwatch? watch = measureBuildTime ? Stopwatch() : null;
|
||||
final Stopwatch watch = measureBuildTime ? Stopwatch() : null;
|
||||
watch?.start();
|
||||
await evalFlutter('build', options: <String>[
|
||||
'web',
|
||||
@@ -1093,7 +1091,7 @@ class WebCompileTest {
|
||||
metrics.addAll(await getSize(outputFileName, metric: metric));
|
||||
|
||||
if (measureBuildTime) {
|
||||
metrics['${metric}_dart2js_millis'] = watch!.elapsedMilliseconds;
|
||||
metrics['${metric}_dart2js_millis'] = watch.elapsedMilliseconds;
|
||||
}
|
||||
|
||||
return metrics;
|
||||
@@ -1101,7 +1099,7 @@ class WebCompileTest {
|
||||
}
|
||||
|
||||
/// Obtains the size and gzipped size of a file given by [fileName].
|
||||
static Future<Map<String, int>> getSize(String fileName, {required String metric}) async {
|
||||
static Future<Map<String, int>> getSize(String fileName, {String metric}) async {
|
||||
final Map<String, int> sizeMetrics = <String, int>{};
|
||||
|
||||
final ProcessResult result = await Process.run('du', <String>['-k', fileName]);
|
||||
@@ -1170,12 +1168,10 @@ class CompileTest {
|
||||
await flutter('build', options: options);
|
||||
watch.stop();
|
||||
final Directory appBuildDirectory = dir(path.join(cwd, 'build/ios/Release-iphoneos'));
|
||||
final Directory? appBundle = appBuildDirectory
|
||||
final Directory appBundle = appBuildDirectory
|
||||
.listSync()
|
||||
.whereType<Directory?>()
|
||||
.singleWhere((Directory? directory) =>
|
||||
directory != null && path.extension(directory.path) == '.app',
|
||||
orElse: () => null);
|
||||
.whereType<Directory>()
|
||||
.singleWhere((Directory directory) => path.extension(directory.path) == '.app', orElse: () => null);
|
||||
if (appBundle == null) {
|
||||
throw 'Failed to find app bundle in ${appBuildDirectory.path}';
|
||||
}
|
||||
@@ -1230,8 +1226,8 @@ class CompileTest {
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> _compileDebug({
|
||||
required bool clean,
|
||||
required String metricKey,
|
||||
@required bool clean,
|
||||
@required String metricKey,
|
||||
}) async {
|
||||
if (clean) {
|
||||
await flutter('clean');
|
||||
@@ -1294,9 +1290,9 @@ class CompileTest {
|
||||
fileToMetadata[entry.path] = entry;
|
||||
}
|
||||
|
||||
final _UnzipListEntry libflutter = fileToMetadata['lib/armeabi-v7a/libflutter.so']!;
|
||||
final _UnzipListEntry libapp = fileToMetadata['lib/armeabi-v7a/libapp.so']!;
|
||||
final _UnzipListEntry license = fileToMetadata['assets/flutter_assets/NOTICES.Z']!;
|
||||
final _UnzipListEntry libflutter = fileToMetadata['lib/armeabi-v7a/libflutter.so'];
|
||||
final _UnzipListEntry libapp = fileToMetadata['lib/armeabi-v7a/libapp.so'];
|
||||
final _UnzipListEntry license = fileToMetadata['assets/flutter_assets/NOTICES.Z'];
|
||||
|
||||
return <String, dynamic>{
|
||||
'libflutter_uncompressed_bytes': libflutter.uncompressedSize,
|
||||
@@ -1319,9 +1315,9 @@ class MemoryTest {
|
||||
|
||||
/// Completes when the log line specified in the last call to
|
||||
/// [prepareForNextMessage] is seen by `adb logcat`.
|
||||
Future<void>? get receivedNextMessage => _receivedNextMessage?.future;
|
||||
Completer<void>? _receivedNextMessage;
|
||||
String? _nextMessage;
|
||||
Future<void> get receivedNextMessage => _receivedNextMessage?.future;
|
||||
Completer<void> _receivedNextMessage;
|
||||
String _nextMessage;
|
||||
|
||||
/// Prepares the [receivedNextMessage] future such that it will complete
|
||||
/// when `adb logcat` sees a log line with the given `message`.
|
||||
@@ -1332,8 +1328,8 @@ class MemoryTest {
|
||||
|
||||
int get iterationCount => 10;
|
||||
|
||||
Device? get device => _device;
|
||||
Device? _device;
|
||||
Device get device => _device;
|
||||
Device _device;
|
||||
|
||||
Future<TaskResult> run() {
|
||||
return inDirectory<TaskResult>(project, () async {
|
||||
@@ -1341,13 +1337,13 @@ class MemoryTest {
|
||||
// device.getMemoryStats, etc, aren't implemented for iOS.
|
||||
|
||||
_device = await devices.workingDevice;
|
||||
await device!.unlock();
|
||||
await device.unlock();
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
final StreamSubscription<String> adb = device!.logcat.listen(
|
||||
final StreamSubscription<String> adb = device.logcat.listen(
|
||||
(String data) {
|
||||
if (data.contains('==== MEMORY BENCHMARK ==== $_nextMessage ===='))
|
||||
_receivedNextMessage?.complete();
|
||||
_receivedNextMessage.complete();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1360,12 +1356,12 @@ class MemoryTest {
|
||||
assert(_endMemory.length == iteration + 1);
|
||||
assert(_diffMemory.length == iteration + 1);
|
||||
print('terminating...');
|
||||
await device!.stop(package);
|
||||
await device.stop(package);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
||||
}
|
||||
|
||||
await adb.cancel();
|
||||
await flutter('install', options: <String>['--uninstall-only', '-d', device!.deviceId]);
|
||||
await flutter('install', options: <String>['--uninstall-only', '-d', device.deviceId]);
|
||||
|
||||
final ListStatistics startMemoryStatistics = ListStatistics(_startMemory);
|
||||
final ListStatistics endMemoryStatistics = ListStatistics(_endMemory);
|
||||
@@ -1396,7 +1392,7 @@ class MemoryTest {
|
||||
'--verbose',
|
||||
'--release',
|
||||
'--no-resident',
|
||||
'-d', device!.deviceId,
|
||||
'-d', device.deviceId,
|
||||
test,
|
||||
]);
|
||||
print('awaiting "ready" message...');
|
||||
@@ -1415,7 +1411,7 @@ class MemoryTest {
|
||||
|
||||
prepareForNextMessage('DONE');
|
||||
print('tapping device...');
|
||||
await device!.tap(100, 100);
|
||||
await device.tap(100, 100);
|
||||
print('awaiting "done" message...');
|
||||
await receivedNextMessage;
|
||||
|
||||
@@ -1426,23 +1422,23 @@ class MemoryTest {
|
||||
final List<int> _endMemory = <int>[];
|
||||
final List<int> _diffMemory = <int>[];
|
||||
|
||||
Map<String, dynamic>? _startMemoryUsage;
|
||||
Map<String, dynamic> _startMemoryUsage;
|
||||
|
||||
@protected
|
||||
Future<void> recordStart() async {
|
||||
assert(_startMemoryUsage == null);
|
||||
print('snapshotting memory usage...');
|
||||
_startMemoryUsage = await device!.getMemoryStats(package);
|
||||
_startMemoryUsage = await device.getMemoryStats(package);
|
||||
}
|
||||
|
||||
@protected
|
||||
Future<void> recordEnd() async {
|
||||
assert(_startMemoryUsage != null);
|
||||
print('snapshotting memory usage...');
|
||||
final Map<String, dynamic> endMemoryUsage = await device!.getMemoryStats(package);
|
||||
_startMemory.add(_startMemoryUsage!['total_kb'] as int);
|
||||
final Map<String, dynamic> endMemoryUsage = await device.getMemoryStats(package);
|
||||
_startMemory.add(_startMemoryUsage['total_kb'] as int);
|
||||
_endMemory.add(endMemoryUsage['total_kb'] as int);
|
||||
_diffMemory.add((endMemoryUsage['total_kb'] as int) - (_startMemoryUsage!['total_kb'] as int));
|
||||
_diffMemory.add((endMemoryUsage['total_kb'] as int) - (_startMemoryUsage['total_kb'] as int));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1491,7 +1487,7 @@ class DevToolsMemoryTest {
|
||||
});
|
||||
}
|
||||
|
||||
late Device _device;
|
||||
Device _device;
|
||||
|
||||
static const String _kJsonFileName = 'devtools_memory.json';
|
||||
}
|
||||
@@ -1509,6 +1505,7 @@ String _reportedDurationTestToString(ReportedDurationTestFlavor flavor) {
|
||||
case ReportedDurationTestFlavor.release:
|
||||
return 'release';
|
||||
}
|
||||
throw ArgumentError('Unexpected value for enum $flavor');
|
||||
}
|
||||
|
||||
class ReportedDurationTest {
|
||||
@@ -1524,8 +1521,8 @@ class ReportedDurationTest {
|
||||
|
||||
int get iterationCount => 10;
|
||||
|
||||
Device? get device => _device;
|
||||
Device? _device;
|
||||
Device get device => _device;
|
||||
Device _device;
|
||||
|
||||
Future<TaskResult> run() {
|
||||
return inDirectory<TaskResult>(project, () async {
|
||||
@@ -1533,13 +1530,13 @@ class ReportedDurationTest {
|
||||
// device.getMemoryStats, etc, aren't implemented for iOS.
|
||||
|
||||
_device = await devices.workingDevice;
|
||||
await device!.unlock();
|
||||
await device.unlock();
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
final StreamSubscription<String> adb = device!.logcat.listen(
|
||||
final StreamSubscription<String> adb = device.logcat.listen(
|
||||
(String data) {
|
||||
if (durationPattern.hasMatch(data))
|
||||
durationCompleter.complete(int.parse(durationPattern.firstMatch(data)!.group(1)!));
|
||||
durationCompleter.complete(int.parse(durationPattern.firstMatch(data).group(1)));
|
||||
},
|
||||
);
|
||||
print('launching $project$test on device...');
|
||||
@@ -1549,13 +1546,13 @@ class ReportedDurationTest {
|
||||
'--no-fast-start',
|
||||
'--${_reportedDurationTestToString(flavor)}',
|
||||
'--no-resident',
|
||||
'-d', device!.deviceId,
|
||||
'-d', device.deviceId,
|
||||
test,
|
||||
]);
|
||||
|
||||
final int duration = await durationCompleter.future;
|
||||
print('terminating...');
|
||||
await device!.stop(package);
|
||||
await device.stop(package);
|
||||
await adb.cancel();
|
||||
|
||||
_device = null;
|
||||
@@ -1610,9 +1607,9 @@ class _UnzipListEntry {
|
||||
}
|
||||
|
||||
_UnzipListEntry._({
|
||||
required this.uncompressedSize,
|
||||
required this.compressedSize,
|
||||
required this.path,
|
||||
@required this.uncompressedSize,
|
||||
@required this.compressedSize,
|
||||
@required this.path,
|
||||
}) : assert(uncompressedSize != null),
|
||||
assert(compressedSize != null),
|
||||
assert(compressedSize <= uncompressedSize),
|
||||
@@ -1636,7 +1633,7 @@ Future<File> waitForFile(String path) async {
|
||||
throw StateError('Did not find vmservice out file after 400 seconds');
|
||||
}
|
||||
|
||||
String? _findIosAppInBuildDirectory(String searchDirectory) {
|
||||
String _findIosAppInBuildDirectory(String searchDirectory) {
|
||||
for (final FileSystemEntity entity in Directory(searchDirectory).listSync()) {
|
||||
if (entity.path.endsWith('.app')) {
|
||||
return entity.path;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:io' show Process, Directory;
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart' as adb;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
@@ -29,8 +31,8 @@ class PluginTest {
|
||||
|
||||
final String buildTarget;
|
||||
final List<String> options;
|
||||
final Map<String, String>? pluginCreateEnvironment;
|
||||
final Map<String, String>? appCreateEnvironment;
|
||||
final Map<String, String> pluginCreateEnvironment;
|
||||
final Map<String, String> appCreateEnvironment;
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
final Directory tempDir =
|
||||
@@ -75,7 +77,7 @@ class _FlutterProject {
|
||||
|
||||
String get rootPath => path.join(parent.path, name);
|
||||
|
||||
Future<void> addPlugin(String plugin, {String? pluginPath}) async {
|
||||
Future<void> addPlugin(String plugin, {String pluginPath}) async {
|
||||
final File pubspec = File(path.join(rootPath, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
final String dependency =
|
||||
@@ -98,9 +100,9 @@ class _FlutterProject {
|
||||
List<String> options,
|
||||
String target,
|
||||
{
|
||||
required String name,
|
||||
required String template,
|
||||
Map<String, String>? environment,
|
||||
String name,
|
||||
String template,
|
||||
Map<String, String> environment,
|
||||
}) async {
|
||||
await inDirectory(directory, () async {
|
||||
await flutter(
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert' show json;
|
||||
import 'dart:io' as io;
|
||||
@@ -11,6 +13,7 @@ import 'package:flutter_devicelab/framework/browser.dart';
|
||||
import 'package:flutter_devicelab/framework/task_result.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:shelf/shelf.dart';
|
||||
import 'package:shelf/shelf_io.dart' as shelf_io;
|
||||
@@ -20,7 +23,7 @@ import 'package:shelf_static/shelf_static.dart';
|
||||
const int benchmarkServerPort = 9999;
|
||||
const int chromeDebugPort = 10000;
|
||||
|
||||
Future<TaskResult> runWebBenchmark({ required bool useCanvasKit }) async {
|
||||
Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async {
|
||||
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
||||
Logger.root.level = Level.INFO;
|
||||
final String macrobenchmarksDirectory = path.join(flutterDirectory.path, 'dev', 'benchmarks', 'macrobenchmarks');
|
||||
@@ -35,17 +38,17 @@ Future<TaskResult> runWebBenchmark({ required bool useCanvasKit }) async {
|
||||
]);
|
||||
final Completer<List<Map<String, dynamic>>> profileData = Completer<List<Map<String, dynamic>>>();
|
||||
final List<Map<String, dynamic>> collectedProfiles = <Map<String, dynamic>>[];
|
||||
List<String>? benchmarks;
|
||||
late Iterator<String> benchmarkIterator;
|
||||
List<String> benchmarks;
|
||||
Iterator<String> benchmarkIterator;
|
||||
|
||||
// This future fixes a race condition between the web-page loading and
|
||||
// asking to run a benchmark, and us connecting to Chrome's DevTools port.
|
||||
// Sometime one wins. Other times, the other wins.
|
||||
Future<Chrome>? whenChromeIsReady;
|
||||
Chrome? chrome;
|
||||
late io.HttpServer server;
|
||||
Future<Chrome> whenChromeIsReady;
|
||||
Chrome chrome;
|
||||
io.HttpServer server;
|
||||
Cascade cascade = Cascade();
|
||||
List<Map<String, dynamic>>? latestPerformanceTrace;
|
||||
List<Map<String, dynamic>> latestPerformanceTrace;
|
||||
cascade = cascade.add((Request request) async {
|
||||
try {
|
||||
chrome ??= await whenChromeIsReady;
|
||||
@@ -63,7 +66,7 @@ Future<TaskResult> runWebBenchmark({ required bool useCanvasKit }) async {
|
||||
|
||||
// Trace data is null when the benchmark is not frame-based, such as RawRecorder.
|
||||
if (latestPerformanceTrace != null) {
|
||||
final BlinkTraceSummary traceSummary = BlinkTraceSummary.fromJson(latestPerformanceTrace!)!;
|
||||
final BlinkTraceSummary traceSummary = BlinkTraceSummary.fromJson(latestPerformanceTrace);
|
||||
profile['totalUiFrame.average'] = traceSummary.averageTotalUIFrameTime.inMicroseconds;
|
||||
profile['scoreKeys'] ??= <dynamic>[]; // using dynamic for consistency with JSON
|
||||
(profile['scoreKeys'] as List<dynamic>).add('totalUiFrame.average');
|
||||
@@ -73,10 +76,10 @@ Future<TaskResult> runWebBenchmark({ required bool useCanvasKit }) async {
|
||||
return Response.ok('Profile received');
|
||||
} else if (request.requestedUri.path.endsWith('/start-performance-tracing')) {
|
||||
latestPerformanceTrace = null;
|
||||
await chrome!.beginRecordingPerformance(request.requestedUri.queryParameters['label']!);
|
||||
await chrome.beginRecordingPerformance(request.requestedUri.queryParameters['label']);
|
||||
return Response.ok('Started performance tracing');
|
||||
} else if (request.requestedUri.path.endsWith('/stop-performance-tracing')) {
|
||||
latestPerformanceTrace = await chrome!.endRecordingPerformance();
|
||||
latestPerformanceTrace = await chrome.endRecordingPerformance();
|
||||
return Response.ok('Stopped performance tracing');
|
||||
} else if (request.requestedUri.path.endsWith('/on-error')) {
|
||||
final Map<String, dynamic> errorDetails = json.decode(await request.readAsString()) as Map<String, dynamic>;
|
||||
@@ -87,7 +90,7 @@ Future<TaskResult> runWebBenchmark({ required bool useCanvasKit }) async {
|
||||
} else if (request.requestedUri.path.endsWith('/next-benchmark')) {
|
||||
if (benchmarks == null) {
|
||||
benchmarks = (json.decode(await request.readAsString()) as List<dynamic>).cast<String>();
|
||||
benchmarkIterator = benchmarks!.iterator;
|
||||
benchmarkIterator = benchmarks.iterator;
|
||||
}
|
||||
if (benchmarkIterator.moveNext()) {
|
||||
final String nextBenchmark = benchmarkIterator.current;
|
||||
@@ -183,7 +186,7 @@ Future<TaskResult> runWebBenchmark({ required bool useCanvasKit }) async {
|
||||
}
|
||||
return TaskResult.success(taskResult, benchmarkScoreKeys: benchmarkScoreKeys);
|
||||
} finally {
|
||||
unawaited(server.close());
|
||||
unawaited(server?.close());
|
||||
chrome?.stop();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
Reference in New Issue
Block a user