mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:28:02 +00:00
c349f992a6
Bug: b/298173463 Change-Id: Ia9d1672e2561e6b35ed5d3c88f8704628857ce7b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328480 Commit-Queue: William Hesse <whesse@google.com> Auto-Submit: Jonas Termansen <sortie@google.com> Reviewed-by: William Hesse <whesse@google.com>
90 lines
2.3 KiB
Dart
90 lines
2.3 KiB
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Reports the sizes of binary artifacts shipped with the SDK.
|
|
|
|
import 'dart:io';
|
|
|
|
const executables = <String>[
|
|
'dart',
|
|
'dartaotruntime',
|
|
];
|
|
|
|
const libs = <String>[
|
|
'vm_platform_strong.dill',
|
|
'vm_platform_strong_product.dill',
|
|
];
|
|
|
|
const snapshots = <String>[
|
|
'analysis_server',
|
|
'dart2js',
|
|
'dart2wasm',
|
|
'dartdev',
|
|
'dartdevc',
|
|
'dds_aot',
|
|
'frontend_server',
|
|
'gen_kernel',
|
|
'kernel-service',
|
|
'kernel_worker',
|
|
];
|
|
|
|
const resources = <String>[
|
|
'devtools',
|
|
];
|
|
|
|
void reportFileSize(String path, String name) {
|
|
try {
|
|
final size = File(path).lengthSync();
|
|
print('SDKArtifactSizes.$name(CodeSize): $size');
|
|
} on FileSystemException {
|
|
// Report dummy data for artifacts that don't exist for specific platforms.
|
|
print('SDKArtifactSizes.$name(CodeSize): 0');
|
|
}
|
|
}
|
|
|
|
void reportDirectorySize(String path, String name) async {
|
|
final dir = Directory(path);
|
|
|
|
try {
|
|
final size = dir
|
|
.listSync(recursive: true, followLinks: false)
|
|
.whereType<File>()
|
|
.map((file) => file.lengthSync())
|
|
.fold<int>(0, (a, b) => a + b);
|
|
print('SDKArtifactSizes.$name(CodeSize): $size');
|
|
} on FileSystemException {
|
|
// Report dummy data on errors.
|
|
print('SDKArtifactSizes.$name(CodeSize): 0');
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
final topDirIndex =
|
|
Platform.resolvedExecutable.lastIndexOf(Platform.pathSeparator);
|
|
final rootDir = Platform.resolvedExecutable.substring(0, topDirIndex);
|
|
|
|
for (final executable in executables) {
|
|
final executablePath = '$rootDir/dart-sdk/bin/$executable';
|
|
reportFileSize(executablePath, executable);
|
|
}
|
|
|
|
for (final lib in libs) {
|
|
final libPath = '$rootDir/dart-sdk/lib/_internal/$lib';
|
|
reportFileSize(libPath, lib);
|
|
}
|
|
|
|
for (final snapshot in snapshots) {
|
|
final snapshotPath =
|
|
'$rootDir/dart-sdk/bin/snapshots/$snapshot.dart.snapshot';
|
|
reportFileSize(snapshotPath, snapshot);
|
|
}
|
|
|
|
for (final resource in resources) {
|
|
final resourcePath = '$rootDir/dart-sdk/bin/resources/$resource';
|
|
reportDirectorySize(resourcePath, resource);
|
|
}
|
|
|
|
// Measure the sdk size.
|
|
reportDirectorySize('$rootDir/dart-sdk', 'sdk');
|
|
}
|