Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CsvBuilder {

void writeHeaders({required int averageOf}) {
writeLines([
'Flutter DevTools performance benchmarks diff: dart2wasm diffed against dart2js.',
'Flutter DevTools performance benchmarks diff: dart2js (baseline) vs dart2wasm (test).',
'Benchmark results were averaged over $averageOf benchmark run(s).',
'',
'These results were auto-generated by a script:',
Expand All @@ -105,9 +105,8 @@ class CsvBuilder {
]);

// Write the Flutter and DevTools commit hash for the benchmark run.
// TODO(kenz): automatically detect these and write them to the CSV.
const flutter = '<enter manually by running \'flutter --version\'>';
const devtools = '<enter manually by running \'git log\'>';
final flutter = _detectFlutterVersion();
final devtools = _detectDevToolsCommit();
writeLines([
'Version info:',
'Flutter: $flutter',
Expand All @@ -120,7 +119,8 @@ class CsvBuilder {
writeLine([
'Benchmark Name',
'Metric',
'Value (micros)',
'Baseline (micros)',
'Test (micros)',
'Delta (micros)',
'Delta (%)',
]);
Expand Down Expand Up @@ -178,6 +178,49 @@ class CsvBuilder {
'(Google Sheets, Excel, etc.) for viewing.',
);
}

String _detectFlutterVersion() {
try {
final result = Process.runSync('flutter', [
'--version',
'--machine',
], runInShell: true);
if (result.exitCode == 0) {
final json =
jsonDecode(result.stdout.toString()) as Map<String, Object?>;
final flutterVersion = json['flutterVersion'];
final frameworkRevision = json['frameworkRevision'];
if (flutterVersion != null && frameworkRevision != null) {
return '$flutterVersion (revision $frameworkRevision)';
}
return result.stdout.toString().trim();
}
} catch (_) {}

try {
final result = Process.runSync('flutter', [
'--version',
], runInShell: true);
if (result.exitCode == 0) {
return result.stdout.toString().trim().split('\n').first;
}
} catch (_) {}

return '<unknown>';
}
Comment thread
kenzieschmoll marked this conversation as resolved.

String _detectDevToolsCommit() {
try {
final result = Process.runSync('git', [
'rev-parse',
'HEAD',
], runInShell: true);
if (result.exitCode == 0) {
return result.stdout.toString().trim();
}
} catch (_) {}
return '<unknown>';
}
Comment thread
kenzieschmoll marked this conversation as resolved.
}

Future<BenchmarkResults> runBenchmarkOrUseExisting(
Expand Down
20 changes: 14 additions & 6 deletions packages/devtools_app/benchmark/scripts/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,22 @@ extension BenchmarkResultsExtension on BenchmarkResults {

extension BenchmarkScoreExtension on BenchmarkScore {
List<String> toCsvLine() {
final deltaValue = delta;
final baselineValue = deltaValue != null ? value - deltaValue : null;
final String deltaPercent;
if (baselineValue == null) {
deltaPercent = '';
} else if (baselineValue == 0) {
deltaPercent = 'N/A';
} else {
deltaPercent = (deltaValue! / baselineValue).toString();
}
return [
metric, // Metric name
value.toString(), // Value
delta?.toString() ?? '', // Delta value
// value - delta represents the baseline score.
delta != null
? (delta! / (value - delta!)).toString()
: '', // Delta % value
baselineValue?.toString() ?? '', // Baseline value
value.toString(), // Test value
deltaValue?.toString() ?? '', // Delta value
deltaPercent, // Delta % value
];
}
}
4 changes: 1 addition & 3 deletions packages/devtools_app/benchmark/test_infra/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
/// found" in DevTools.
const _benchmarkInitialPage = '';

const _wasmQueryParameters = {'compiler': 'wasm'};

String benchmarkPath({required bool useWasm}) => Uri(
path: _benchmarkInitialPage,
queryParameters: useWasm ? _wasmQueryParameters : null,
queryParameters: {'compiler': useWasm ? 'wasm' : 'js'},
).toString();

String generateBenchmarkEntryPoint({required bool useWasm}) {
Expand Down
Loading