Skip to content

Commit 06ecbba

Browse files
[benchmarks] Allow passing --local-web-sdk and --build-mode flags to benchmarks (flutter#175199)
This allows setting the `--local-web-sdk` and `--build-mode` flags to benchmarks. This makes it easier to debug benchmarks that only fail with local engine changes. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 715b4d8 commit 06ecbba

10 files changed

Lines changed: 61 additions & 1 deletion

dev/devicelab/bin/run.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Future<void> main(List<String> rawArgs) async {
3232
/// Suppresses standard output, prints only standard error output.
3333
final bool silent = (args['silent'] as bool?) ?? false;
3434

35+
final String buildMode = args['build-mode'] as String;
36+
3537
/// The build of the local engine to use.
3638
///
3739
/// Required for A/B test mode.
@@ -120,6 +122,7 @@ Future<void> main(List<String> rawArgs) async {
120122
resultsFile: resultsFile,
121123
taskName: taskNames.single,
122124
onlyLocalEngine: (args['ab-local-engine-only'] as bool?) ?? false,
125+
buildMode: buildMode,
123126
);
124127
} else {
125128
await runTasks(
@@ -128,13 +131,15 @@ Future<void> main(List<String> rawArgs) async {
128131
localEngine: localEngine,
129132
localEngineHost: localEngineHost,
130133
localEngineSrcPath: localEngineSrcPath,
134+
localWebSdk: localWebSdk,
131135
deviceId: deviceId,
132136
exitOnFirstTestFailure: exitOnFirstTestFailure,
133137
terminateStrayDartProcesses: terminateStrayDartProcesses,
134138
gitBranch: gitBranch,
135139
luciBuilder: luciBuilder,
136140
resultsPath: resultsPath,
137141
useEmulator: useEmulator,
142+
buildMode: buildMode,
138143
);
139144
}
140145
}
@@ -145,6 +150,7 @@ Future<void> _runABTest({
145150
required String? localEngine,
146151
required String? localEngineHost,
147152
required String? localWebSdk,
153+
required String buildMode,
148154
required String? localEngineSrcPath,
149155
required String? deviceId,
150156
required String resultsFile,
@@ -171,6 +177,7 @@ Future<void> _runABTest({
171177
taskName,
172178
silent: silent,
173179
deviceId: deviceId,
180+
buildMode: buildMode,
174181
);
175182

176183
print('Default engine result:');
@@ -192,6 +199,7 @@ Future<void> _runABTest({
192199
localEngineHost: localEngineHost,
193200
localWebSdk: localWebSdk,
194201
localEngineSrcPath: localEngineSrcPath,
202+
buildMode: buildMode,
195203
deviceId: deviceId,
196204
);
197205

@@ -255,6 +263,12 @@ ArgParser createArgParser(List<String> taskNames) {
255263
taskNames.addAll(tasks);
256264
},
257265
)
266+
..addOption(
267+
'build-mode',
268+
defaultsTo: 'profile',
269+
allowed: <String>['debug', 'profile'],
270+
help: 'The build mode to use for the benchmark.',
271+
)
258272
..addOption(
259273
'device-id',
260274
abbr: 'd',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_devicelab/framework/framework.dart';
6+
import 'package:flutter_devicelab/framework/task_result.dart';
7+
8+
const String buildMode = String.fromEnvironment('buildMode');
9+
10+
Future<void> main() async {
11+
await task(() async {
12+
print('buildMode: $buildMode');
13+
return TaskResult.success(null);
14+
});
15+
}

dev/devicelab/bin/tasks/web_benchmarks_canvaskit.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import 'package:flutter_devicelab/framework/framework.dart';
66
import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
77

8+
const String buildMode = String.fromEnvironment('buildMode', defaultValue: 'profile');
9+
810
/// Runs all Web benchmarks using the CanvasKit rendering backend.
911
Future<void> main() async {
1012
await task(() async {
@@ -13,6 +15,7 @@ Future<void> main() async {
1315
forceSingleThreadedSkwasm: false,
1416
useDdc: false,
1517
withHotReload: false,
18+
buildMode: buildMode,
1619
));
1720
});
1821
}

dev/devicelab/bin/tasks/web_benchmarks_ddc.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Future<void> main() async {
1313
forceSingleThreadedSkwasm: false,
1414
useDdc: true,
1515
withHotReload: false,
16+
buildMode: 'debug',
1617
));
1718
});
1819
}

dev/devicelab/bin/tasks/web_benchmarks_ddc_hot_reload.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Future<void> main() async {
1313
forceSingleThreadedSkwasm: false,
1414
useDdc: true,
1515
withHotReload: true,
16+
buildMode: 'debug',
1617
));
1718
});
1819
}

dev/devicelab/bin/tasks/web_benchmarks_skwasm.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import 'package:flutter_devicelab/framework/framework.dart';
66
import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
77

8+
const String buildMode = String.fromEnvironment('buildMode', defaultValue: 'profile');
9+
810
/// Runs all Web benchmarks using the Skwasm rendering backend.
911
Future<void> main() async {
1012
await task(() async {
@@ -13,6 +15,7 @@ Future<void> main() async {
1315
forceSingleThreadedSkwasm: false,
1416
useDdc: false,
1517
withHotReload: false,
18+
buildMode: buildMode,
1619
));
1720
});
1821
}

dev/devicelab/bin/tasks/web_benchmarks_skwasm_st.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import 'package:flutter_devicelab/framework/framework.dart';
66
import 'package:flutter_devicelab/tasks/web_benchmarks.dart';
77

8+
const String buildMode = String.fromEnvironment('buildMode', defaultValue: 'profile');
9+
810
/// Runs all Web benchmarks using the Skwasm rendering backend.
911
Future<void> main() async {
1012
await task(() async {
@@ -13,6 +15,7 @@ Future<void> main() async {
1315
forceSingleThreadedSkwasm: true,
1416
useDdc: false,
1517
withHotReload: false,
18+
buildMode: buildMode,
1619
));
1720
});
1821
}

dev/devicelab/lib/framework/runner.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ Future<void> runTasks(
3838
String? localEngine,
3939
String? localEngineHost,
4040
String? localEngineSrcPath,
41+
String? localWebSdk,
4142
String? luciBuilder,
4243
String? resultsPath,
4344
List<String>? taskArgs,
4445
bool useEmulator = false,
46+
String buildMode = 'profile',
4547
@visibleForTesting Map<String, String>? isolateParams,
4648
@visibleForTesting void Function(String) print = print,
4749
@visibleForTesting List<String>? logs,
@@ -56,6 +58,7 @@ Future<void> runTasks(
5658
localEngine: localEngine,
5759
localEngineHost: localEngineHost,
5860
localEngineSrcPath: localEngineSrcPath,
61+
localWebSdk: localWebSdk,
5962
terminateStrayDartProcesses: terminateStrayDartProcesses,
6063
silent: silent,
6164
taskArgs: taskArgs,
@@ -64,6 +67,7 @@ Future<void> runTasks(
6467
luciBuilder: luciBuilder,
6568
isolateParams: isolateParams,
6669
useEmulator: useEmulator,
70+
buildMode: buildMode,
6771
);
6872

6973
if (!result.succeeded) {
@@ -109,13 +113,15 @@ Future<TaskResult> rerunTask(
109113
String? localEngine,
110114
String? localEngineHost,
111115
String? localEngineSrcPath,
116+
String? localWebSdk,
112117
bool terminateStrayDartProcesses = false,
113118
bool silent = false,
114119
List<String>? taskArgs,
115120
String? resultsPath,
116121
String? gitBranch,
117122
String? luciBuilder,
118123
bool useEmulator = false,
124+
String buildMode = 'profile',
119125
@visibleForTesting Map<String, String>? isolateParams,
120126
}) async {
121127
section('Running task "$taskName"');
@@ -125,11 +131,13 @@ Future<TaskResult> rerunTask(
125131
localEngine: localEngine,
126132
localEngineHost: localEngineHost,
127133
localEngineSrcPath: localEngineSrcPath,
134+
localWebSdk: localWebSdk,
128135
terminateStrayDartProcesses: terminateStrayDartProcesses,
129136
silent: silent,
130137
taskArgs: taskArgs,
131138
isolateParams: isolateParams,
132139
useEmulator: useEmulator,
140+
buildMode: buildMode,
133141
);
134142

135143
print('Task result:');
@@ -169,6 +177,7 @@ Future<TaskResult> runTask(
169177
String? deviceId,
170178
List<String>? taskArgs,
171179
bool useEmulator = false,
180+
String buildMode = 'profile',
172181
@visibleForTesting Map<String, String>? isolateParams,
173182
}) async {
174183
final String taskExecutable = 'bin/tasks/$taskName.dart';
@@ -192,6 +201,7 @@ Future<TaskResult> runTask(
192201
<String>[
193202
'--enable-vm-service=0', // zero causes the system to choose a free port
194203
'--no-pause-isolates-on-exit',
204+
'-DbuildMode=$buildMode',
195205
if (localEngine != null) '-DlocalEngine=$localEngine',
196206
if (localEngineHost != null) '-DlocalEngineHost=$localEngineHost',
197207
if (localWebSdk != null) '-DlocalWebSdk=$localWebSdk',

dev/devicelab/lib/tasks/web_benchmarks.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef WebBenchmarkOptions = ({
3131
bool forceSingleThreadedSkwasm,
3232
bool useDdc,
3333
bool withHotReload,
34+
String buildMode,
3435
});
3536

3637
Future<TaskResult> runWebBenchmark(WebBenchmarkOptions benchmarkOptions) async {
@@ -107,7 +108,7 @@ Future<TaskResult> runWebBenchmark(WebBenchmarkOptions benchmarkOptions) async {
107108
'--no-tree-shake-icons', // local engine builds are frequently out of sync with the Dart Kernel version
108109
if (benchmarkOptions.useWasm) ...<String>['--wasm', '--no-strip-wasm'],
109110
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
110-
'--profile',
111+
'--${benchmarkOptions.buildMode}',
111112
'--no-web-resources-cdn',
112113
'-t',
113114
'lib/web_benchmarks.dart',

dev/devicelab/test/run_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,14 @@ void main() {
192192
);
193193
expect(result.exitCode, 1);
194194
});
195+
196+
test('passes build mode to the test', () async {
197+
final ProcessResult result = await runScript(
198+
<String>['build_mode_test'],
199+
<String>['--build-mode=debug'],
200+
);
201+
expect(result.exitCode, 0);
202+
expect(result.stdout, contains('buildMode: debug'));
203+
});
195204
});
196205
}

0 commit comments

Comments
 (0)