mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

**Three things** Re-lands #154374 New: fix `platform_channels_benchmarks` to print the "done" key. Updated notes for the microbenchmark parser. There are no other users of `microbenchmarks.readJsonResults`. Re-Re-land: Uninstall microbenchmarks before running them. Flakes in https://github.com/flutter/flutter/issues/153828 stem from adb saying the app isn't installed, but then failing to install wtih -r. Several other tests uninstall the app before trying to run it. Previous fix called uninstall between tests, but iOS takes 12 to 13 seconds to perform uninstall / install, which timed out the test. Just uninstall the one time since we only care about any lingering apps with different keys. Potential solution https://github.com/flutter/flutter/issues/153828 Re-land Make things go fast Instead of installing 21 different compilations of the same app to get results; compile and run them together. Locally on Mac+iOS, this should takes ~3 minutes instead of ~15 minutes.
80 lines
2.3 KiB
Dart
80 lines
2.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:path/path.dart' as path;
|
|
|
|
import '../framework/devices.dart';
|
|
import '../framework/framework.dart';
|
|
import '../framework/task_result.dart';
|
|
import '../framework/utils.dart';
|
|
import '../microbenchmarks.dart';
|
|
|
|
/// Creates a device lab task that runs benchmarks in
|
|
/// `dev/benchmarks/microbenchmarks` reports results to the dashboard.
|
|
TaskFunction createMicrobenchmarkTask({
|
|
bool? enableImpeller,
|
|
Map<String, String> environment = const <String, String>{},
|
|
}) {
|
|
return () async {
|
|
final Device device = await devices.workingDevice;
|
|
await device.unlock();
|
|
await device.clearLogs();
|
|
|
|
final Directory appDir =
|
|
dir(path.join(flutterDirectory.path, 'dev/benchmarks/microbenchmarks'));
|
|
|
|
// Hard-uninstall any prior apps.
|
|
await inDirectory(appDir, () async {
|
|
section('Uninstall previous microbenchmarks app');
|
|
await flutter(
|
|
'install',
|
|
options: <String>[
|
|
'-v',
|
|
'--uninstall-only',
|
|
'-d',
|
|
device.deviceId,
|
|
],
|
|
);
|
|
});
|
|
|
|
Future<Map<String, double>> runMicrobench(String benchmarkPath) async {
|
|
Future<Map<String, double>> run() async {
|
|
print('Running $benchmarkPath');
|
|
|
|
final Process flutterProcess = await inDirectory(appDir, () async {
|
|
final List<String> options = <String>[
|
|
'-v',
|
|
// --release doesn't work on iOS due to code signing issues
|
|
'--profile',
|
|
'--no-publish-port',
|
|
if (enableImpeller != null && enableImpeller) '--enable-impeller',
|
|
if (enableImpeller != null && !enableImpeller) '--no-enable-impeller',
|
|
'-d',
|
|
device.deviceId,
|
|
benchmarkPath,
|
|
];
|
|
return startFlutter(
|
|
'run',
|
|
options: options,
|
|
environment: environment,
|
|
);
|
|
});
|
|
return readJsonResults(flutterProcess);
|
|
}
|
|
|
|
return run();
|
|
}
|
|
|
|
final Map<String, double> allResults = <String, double>{
|
|
...await runMicrobench('lib/benchmark_collection.dart'),
|
|
};
|
|
|
|
return TaskResult.success(allResults,
|
|
benchmarkScoreKeys: allResults.keys.toList());
|
|
};
|
|
}
|