Commit 4bec9cd9 authored by Yegor's avatar Yegor Committed by GitHub

update build benchmark to match #7589 (#7600)

parent a6777b2a
...@@ -237,6 +237,14 @@ Future<int> flutter(String command, ...@@ -237,6 +237,14 @@ Future<int> flutter(String command,
canFail: canFail, env: env); canFail: canFail, env: env);
} }
/// Runs a `flutter` command and returns the standard output as a string.
Future<String> evalFlutter(String command,
{List<String> options: const <String>[], bool canFail: false, Map<String, String> env}) {
List<String> args = <String>[command]..addAll(options);
return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
canFail: canFail, env: env);
}
String get dartBin => String get dartBin =>
path.join(flutterDirectory.path, 'bin', 'cache', 'dart-sdk', 'bin', 'dart'); path.join(flutterDirectory.path, 'bin', 'cache', 'dart-sdk', 'bin', 'dart');
......
...@@ -164,38 +164,42 @@ class BuildTest { ...@@ -164,38 +164,42 @@ class BuildTest {
await flutter('packages', options: <String>['get']); await flutter('packages', options: <String>['get']);
Stopwatch watch = new Stopwatch()..start(); Stopwatch watch = new Stopwatch()..start();
await flutter('build', options: <String>[ String buildLog = await evalFlutter('build', options: <String>[
'aot', 'aot',
'-v',
'--profile', '--profile',
'--no-pub', '--no-pub',
'--target-platform', 'android-arm' // Generate blobs instead of assembly. '--target-platform', 'android-arm' // Generate blobs instead of assembly.
]); ]);
watch.stop(); watch.stop();
int vmisolateSize = file("$testDirectory/build/aot/snapshot_aot_vmisolate").lengthSync(); RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
int isolateSize = file("$testDirectory/build/aot/snapshot_aot_isolate").lengthSync();
int instructionsSize = file("$testDirectory/build/aot/snapshot_aot_instr").lengthSync();
int rodataSize = file("$testDirectory/build/aot/snapshot_aot_rodata").lengthSync();
int totalSize = vmisolateSize + isolateSize + instructionsSize + rodataSize;
Map<String, dynamic> data = <String, dynamic>{ Map<String, dynamic> data = new Map<String, dynamic>.fromIterable(
'aot_snapshot_build_millis': watch.elapsedMilliseconds, metricExpression.allMatches(buildLog),
'aot_snapshot_size_vmisolate': vmisolateSize, key: (Match m) => _sdkNameToMetricName(m.group(1)),
'aot_snapshot_size_isolate': isolateSize, value: (Match m) => int.parse(m.group(2)),
'aot_snapshot_size_instructions': instructionsSize, );
'aot_snapshot_size_rodata': rodataSize, data['aot_snapshot_build_millis'] = watch.elapsedMilliseconds;
'aot_snapshot_size_total': totalSize,
}; return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
return new TaskResult.success(data, benchmarkScoreKeys: <String>[
'aot_snapshot_build_millis',
'aot_snapshot_size_vmisolate',
'aot_snapshot_size_isolate',
'aot_snapshot_size_instructions',
'aot_snapshot_size_rodata',
'aot_snapshot_size_total',
]);
}); });
} }
static String _sdkNameToMetricName(String sdkName) {
const Map<String, String> kSdkNameToMetricNameMapping = const <String, String> {
'VMIsolate': 'aot_snapshot_size_vmisolate',
'Isolate': 'aot_snapshot_size_isolate',
'ReadOnlyData': 'aot_snapshot_size_rodata',
'Instructions': 'aot_snapshot_size_instructions',
'Total': 'aot_snapshot_size_total',
};
if (!kSdkNameToMetricNameMapping.containsKey(sdkName))
throw 'Unrecognized SDK snapshot metric name: $sdkName';
return kSdkNameToMetricNameMapping[sdkName];
}
} }
/// Measure application memory usage. /// Measure application memory usage.
......
...@@ -215,6 +215,7 @@ Future<String> _buildAotSnapshot( ...@@ -215,6 +215,7 @@ Future<String> _buildAotSnapshot(
'--url_mapping=dart:ui,$uiPath', '--url_mapping=dart:ui,$uiPath',
'--url_mapping=dart:jni,$jniPath', '--url_mapping=dart:jni,$jniPath',
'--url_mapping=dart:vmservice_sky,$vmServicePath', '--url_mapping=dart:vmservice_sky,$vmServicePath',
'--print_snapshot_sizes',
]; ];
if (!interpreter) { if (!interpreter) {
......
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