mirror of
https://github.com/dart-lang/sdk
synced 2024-10-02 23:24:42 +00:00
Revise the SDK size benchmark.
Change-Id: Iab9b301737e141a9ad95d4f4e9391a06b5788e6c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210760 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
parent
0a7819ee40
commit
3238d433fa
|
@ -33,9 +33,9 @@ const snapshots = <String>[
|
|||
'pub',
|
||||
];
|
||||
|
||||
Future<void> reportArtifactSize(String path, String name) async {
|
||||
void reportFileSize(String path, String name) {
|
||||
try {
|
||||
final size = await File(path).length();
|
||||
final size = File(path).lengthSync();
|
||||
print('SDKArtifactSizes.$name(CodeSize): $size');
|
||||
} on FileSystemException {
|
||||
// Report dummy data for artifacts that don't exist for specific platforms.
|
||||
|
@ -43,43 +43,43 @@ Future<void> reportArtifactSize(String path, String name) async {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
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';
|
||||
await reportArtifactSize(executablePath, executable);
|
||||
reportFileSize(executablePath, executable);
|
||||
}
|
||||
|
||||
for (final lib in libs) {
|
||||
final libPath = '$rootDir/dart-sdk/lib/_internal/$lib';
|
||||
await reportArtifactSize(libPath, lib);
|
||||
reportFileSize(libPath, lib);
|
||||
}
|
||||
|
||||
for (final snapshot in snapshots) {
|
||||
final snapshotPath =
|
||||
'$rootDir/dart-sdk/bin/snapshots/$snapshot.dart.snapshot';
|
||||
await reportArtifactSize(snapshotPath, snapshot);
|
||||
reportFileSize(snapshotPath, snapshot);
|
||||
}
|
||||
|
||||
// Measure the (compressed) sdk size.
|
||||
final tempDir = Directory.systemTemp.createTempSync('dartdev');
|
||||
final sdkArchive = compress(Directory('$rootDir/dart-sdk'), tempDir);
|
||||
await reportArtifactSize(sdkArchive?.path ?? '', 'sdk');
|
||||
tempDir.deleteSync(recursive: true);
|
||||
}
|
||||
|
||||
File? compress(Directory sourceDir, Directory targetDir) {
|
||||
final outFile = File('${targetDir.path}/sdk.zip');
|
||||
|
||||
if (Platform.isMacOS || Platform.isLinux) {
|
||||
Process.runSync(
|
||||
'zip', ['-r', outFile.absolute.path, sourceDir.absolute.path]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return outFile;
|
||||
// Measure the sdk size.
|
||||
reportDirectorySize('$rootDir/dart-sdk', 'sdk');
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ const snapshots = <String>[
|
|||
'pub',
|
||||
];
|
||||
|
||||
Future<void> reportArtifactSize(String path, String name) async {
|
||||
void reportFileSize(String path, String name) {
|
||||
try {
|
||||
final size = await File(path).length();
|
||||
final size = File(path).lengthSync();
|
||||
print('SDKArtifactSizes.$name(CodeSize): $size');
|
||||
} on FileSystemException {
|
||||
// Report dummy data for artifacts that don't exist for specific platforms.
|
||||
|
@ -45,43 +45,43 @@ Future<void> reportArtifactSize(String path, String name) async {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
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';
|
||||
await reportArtifactSize(executablePath, executable);
|
||||
reportFileSize(executablePath, executable);
|
||||
}
|
||||
|
||||
for (final lib in libs) {
|
||||
final libPath = '$rootDir/dart-sdk/lib/_internal/$lib';
|
||||
await reportArtifactSize(libPath, lib);
|
||||
reportFileSize(libPath, lib);
|
||||
}
|
||||
|
||||
for (final snapshot in snapshots) {
|
||||
final snapshotPath =
|
||||
'$rootDir/dart-sdk/bin/snapshots/$snapshot.dart.snapshot';
|
||||
await reportArtifactSize(snapshotPath, snapshot);
|
||||
reportFileSize(snapshotPath, snapshot);
|
||||
}
|
||||
|
||||
// Measure the (compressed) sdk size.
|
||||
final tempDir = Directory.systemTemp.createTempSync('dartdev');
|
||||
final sdkArchive = compress(Directory('$rootDir/dart-sdk'), tempDir);
|
||||
await reportArtifactSize(sdkArchive?.path ?? '', 'sdk');
|
||||
tempDir.deleteSync(recursive: true);
|
||||
}
|
||||
|
||||
File compress(Directory sourceDir, Directory targetDir) {
|
||||
final outFile = File('${targetDir.path}/sdk.zip');
|
||||
|
||||
if (Platform.isMacOS || Platform.isLinux) {
|
||||
Process.runSync(
|
||||
'zip', ['-r', outFile.absolute.path, sourceDir.absolute.path]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return outFile;
|
||||
// Measure the sdk size.
|
||||
reportDirectorySize('$rootDir/dart-sdk', 'sdk');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue