Skip to content

Add json size to benchmark. #3969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion _benchmark/lib/commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ class MeasureCommand extends Command<void> {
await Future<void>.delayed(const Duration(seconds: 1));

final update = StringBuffer('${config.generator.packageName}\n');
update.write('shape,libraries,clean/ms,no changes/ms,incremental/ms\n');
update.write(
'shape,libraries,clean/ms,no changes/ms,incremental/ms,'
'json/KiB\n',
);
for (final shape in config.shapes) {
for (final size in config.sizes) {
final pendingResult = pendingResults[(shape, size)]!;
Expand All @@ -104,6 +107,7 @@ class MeasureCommand extends Command<void> {
pendingResult.cleanBuildTime.renderFailed,
pendingResult.noChangesBuildTime.renderFailed,
pendingResult.incrementalBuildTime.renderFailed,
pendingResult.graphSize.renderFailed,
].join(','),
);
} else {
Expand All @@ -114,6 +118,7 @@ class MeasureCommand extends Command<void> {
pendingResult.cleanBuildTime.render,
pendingResult.noChangesBuildTime.render,
pendingResult.incrementalBuildTime.render,
pendingResult.graphSize.render,
].join(','),
);
}
Expand All @@ -138,3 +143,11 @@ extension DurationExtension on Duration? {
String get renderFailed =>
this == null ? 'X' : this!.inMilliseconds.toString();
}

extension IntExtension on int? {
/// Renders with `---` for `null`, to mean "pending".
String get render => this == null ? '---' : (this! / 1024).round().toString();

/// Renders with X` for `null`, to mean "failed".
String get renderFailed => this == null ? 'X' : this!.toString();
}
14 changes: 14 additions & 0 deletions _benchmark/lib/workspace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class Workspace {
return;
}

result.graphSize = _readGraphSize();

// Build with no changes.
stopwatch.reset();
process = await Process.start('dart', [
Expand Down Expand Up @@ -111,6 +113,17 @@ class Workspace {
return;
}
}

/// Returns the `build_runner` asset graph size, or `null` if not found.
int? _readGraphSize() {
for (final entry in Directory.fromUri(
directory.uri.resolve('.dart_tool/build'),
).listSync(recursive: true)) {
if (entry is! File) continue;
if (entry.path.endsWith('asset_graph.json')) return entry.lengthSync();
}
return null;
}
}

/// Benchmark results.
Expand All @@ -120,6 +133,7 @@ class PendingResult {
Duration? cleanBuildTime;
Duration? noChangesBuildTime;
Duration? incrementalBuildTime;
int? graphSize;
String? failure;

bool get isFailure => failure != null;
Expand Down