[flutter_tools] restore report timings functionality to build aot (#52918)
This commit is contained in:
@@ -30,6 +30,7 @@ class AotBuilder {
|
||||
bool bitcode = kBitcodeEnabledDefault,
|
||||
bool quiet = true,
|
||||
Iterable<DarwinArch> iosBuildArchs = defaultIOSArchs,
|
||||
bool reportTimings,
|
||||
}) async {
|
||||
if (platform == null) {
|
||||
throwToolExit('No AOT build platform specified');
|
||||
@@ -106,6 +107,21 @@ class AotBuilder {
|
||||
throwToolExit('The aot build failed.');
|
||||
}
|
||||
|
||||
// This print output is used by the dart team for build benchmarks.
|
||||
if (reportTimings) {
|
||||
final PerformanceMeasurement kernel = result.performance['kernel_snapshot'];
|
||||
PerformanceMeasurement aot;
|
||||
if (expectSo) {
|
||||
aot = result.performance.values.firstWhere(
|
||||
(PerformanceMeasurement measurement) => measurement.analyicsName == 'android_aot');
|
||||
} else {
|
||||
aot = result.performance.values.firstWhere(
|
||||
(PerformanceMeasurement measurement) => measurement.analyicsName == 'ios_aot');
|
||||
}
|
||||
globals.printStatus('frontend(CompileTime): ${kernel.elapsedMilliseconds} ms.');
|
||||
globals.printStatus('snapshot(CompileTime): ${aot.elapsedMilliseconds} ms.');
|
||||
}
|
||||
|
||||
if (expectSo) {
|
||||
environment.buildDir.childFile('app.so')
|
||||
.copySync(globals.fs.path.join(outputPath, 'app.so'));
|
||||
|
||||
@@ -114,6 +114,14 @@ abstract class Target {
|
||||
/// argument to build a particular target.
|
||||
String get name;
|
||||
|
||||
/// A name that measurements can be categorized under for this [Target].
|
||||
///
|
||||
/// Unlike [name], this is not expected to be unique, so multiple targets
|
||||
/// that are conceptually the same can share an analytics name.
|
||||
///
|
||||
/// If not provided, defaults to [name]
|
||||
String get analyticsName => name;
|
||||
|
||||
/// The dependencies of this target.
|
||||
List<Target> get dependencies;
|
||||
|
||||
@@ -594,7 +602,12 @@ class _BuildInstance {
|
||||
resource.release();
|
||||
stopwatch.stop();
|
||||
stepTimings[node.target.name] = PerformanceMeasurement(
|
||||
node.target.name, stopwatch.elapsedMilliseconds, skipped, passed);
|
||||
target: node.target.name,
|
||||
elapsedMilliseconds: stopwatch.elapsedMilliseconds,
|
||||
skipped: skipped,
|
||||
passed: passed,
|
||||
analyicsName: node.target.analyticsName,
|
||||
);
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
@@ -617,11 +630,19 @@ class ExceptionMeasurement {
|
||||
|
||||
/// Helper class to collect measurement data.
|
||||
class PerformanceMeasurement {
|
||||
PerformanceMeasurement(this.target, this.elapsedMilliseconds, this.skipped, this.passed);
|
||||
PerformanceMeasurement({
|
||||
@required this.target,
|
||||
@required this.elapsedMilliseconds,
|
||||
@required this.skipped,
|
||||
@required this.passed,
|
||||
@required this.analyicsName,
|
||||
});
|
||||
|
||||
final int elapsedMilliseconds;
|
||||
final String target;
|
||||
final bool skipped;
|
||||
final bool passed;
|
||||
final String analyicsName;
|
||||
}
|
||||
|
||||
/// Check if there are any dependency cycles in the target.
|
||||
|
||||
@@ -257,6 +257,9 @@ class KernelSnapshot extends Target {
|
||||
abstract class AotElfBase extends Target {
|
||||
const AotElfBase();
|
||||
|
||||
@override
|
||||
String get analyticsName => 'android_aot';
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final AOTSnapshotter snapshotter = AOTSnapshotter(
|
||||
|
||||
@@ -26,6 +26,9 @@ import 'icon_tree_shaker.dart';
|
||||
abstract class AotAssemblyBase extends Target {
|
||||
const AotAssemblyBase();
|
||||
|
||||
@override
|
||||
String get analyticsName => 'ios_aot';
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final AOTSnapshotter snapshotter = AOTSnapshotter(
|
||||
|
||||
@@ -45,7 +45,8 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen
|
||||
defaultsTo: kBitcodeEnabledDefault,
|
||||
help: 'Build the AOT bundle with bitcode. Requires a compatible bitcode engine.',
|
||||
hide: true,
|
||||
);
|
||||
)
|
||||
..addFlag('report-timings', hide: true);
|
||||
}
|
||||
|
||||
AotBuilder aotBuilder;
|
||||
@@ -76,6 +77,7 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen
|
||||
bitcode: boolArg('bitcode'),
|
||||
quiet: boolArg('quiet'),
|
||||
iosBuildArchs: stringsArg('ios-arch').map<DarwinArch>(getIOSArchForName),
|
||||
reportTimings: boolArg('report-timings'),
|
||||
);
|
||||
return FlutterCommandResult.success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user