Unverified Commit d52f315c authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Add new benchmark to track cost of dependencies to a User (#23856)

parent 36b99832
......@@ -73,8 +73,20 @@ Future<int> countDependencies() async {
return count;
}
Future<int> countConsumerDependencies() async {
final List<String> lines = (await evalFlutter(
'update-packages',
options: <String>['--transitive-closure', '--consumer-only'],
)).split('\n');
final int count = lines.where((String line) => line.contains('->')).length;
if (count < 2) // we'll always have flutter and flutter_test, at least...
throw Exception('"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}');
return count;
}
const String _kCostBenchmarkKey = 'technical_debt_in_dollars';
const String _kNumberOfDependenciesKey = 'dependencies_count';
const String _kNumberOfConsumerDependenciesKey = 'consumer_dependencies_count';
Future<void> main() async {
await task(() async {
......@@ -82,10 +94,12 @@ Future<void> main() async {
<String, dynamic>{
_kCostBenchmarkKey: await findCostsForRepo(),
_kNumberOfDependenciesKey: await countDependencies(),
_kNumberOfConsumerDependenciesKey: await countConsumerDependencies(),
},
benchmarkScoreKeys: <String>[
_kCostBenchmarkKey,
_kNumberOfDependenciesKey,
_kNumberOfConsumerDependenciesKey,
],
);
});
......
......@@ -65,6 +65,14 @@ class UpdatePackagesCommand extends FlutterCommand {
defaultsTo: false,
negatable: false,
)
..addFlag(
'consumer-only',
help: 'Only prints the dependency graph that is the transitive closure'
'that a consumer of the Flutter SDK will observe (When combined '
'with transitive-closure)',
defaultsTo: false,
negatable: false,
)
..addFlag(
'verify-only',
help: 'verifies the package checksum without changing or updating deps',
......@@ -107,6 +115,24 @@ class UpdatePackagesCommand extends FlutterCommand {
final bool isPrintPaths = argResults['paths'];
final bool isPrintTransitiveClosure = argResults['transitive-closure'];
final bool isVerifyOnly = argResults['verify-only'];
final bool isConsumerOnly = argResults['consumer-only'];
// "consumer" packages are those that constitute our public API (e.g. flutter, flutter_test, flutter_driver, flutter_localizations).
if (isConsumerOnly) {
if (!isPrintTransitiveClosure) {
throwToolExit(
'--consumer-only can only be used with the --transitive-closure flag'
);
}
// Only retain flutter, flutter_test, flutter_driver, and flutter_localizations.
const List<String> consumerPackages = <String>['flutter', 'flutter_test', 'flutter_driver', 'flutter_localizations'];
// ensure we only get flutter/packages
packages.retainWhere((Directory directory) {
return consumerPackages.any((String package) {
return directory.path.endsWith('packages${fs.path.separator}$package');
});
});
}
// The dev/integration_tests/android_views integration test depends on an assets
// package that is in the goldens repository. We need to make sure that the goldens
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment