Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions packages/web_benchmarks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.0+12

* Add the ability to run a benchmark with WebAssembly.

## 0.1.0+11

* Migrates benchmark recorder from `dart:html` to `package:web` to support WebAssembly.
Expand Down
2 changes: 2 additions & 0 deletions packages/web_benchmarks/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Future<BenchmarkResults> serveWebBenchmark({
bool headless = true,
bool treeShakeIcons = true,
String initialPage = defaultInitialPage,
bool useWasm = false,
}) async {
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
Logger.root.level = Level.INFO;
Expand All @@ -62,5 +63,6 @@ Future<BenchmarkResults> serveWebBenchmark({
headless: headless,
treeShakeIcons: treeShakeIcons,
initialPage: initialPage,
useWasm: useWasm,
).run();
}
11 changes: 10 additions & 1 deletion packages/web_benchmarks/lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class BenchmarkServer {
required this.chromeDebugPort,
required this.headless,
required this.treeShakeIcons,
this.useWasm = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this will have the same effect as useCanvasKit above. useCanvasKit ended up being not extensible enough, so we'll need to make a breaking change to accommodate Skwasm. I wonder if we should instead have a CompilationOptions object that can be extended in the future. cc @eyebrowsoffire

Copy link
Member Author

@kenzieschmoll kenzieschmoll Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a CompilationOptions class. PTAL @yjbanov @eyebrowsoffire. Since this is a breaking change, I also did a major version bump - let me know if we want to hold off on bringing this package to '1.0.0'.

this.initialPage = defaultInitialPage,
});

Expand All @@ -75,6 +76,9 @@ class BenchmarkServer {
/// Whether to build the app in CanvasKit mode.
final bool useCanvasKit;

/// Whether to build the app with dart2wasm.
final bool useWasm;

/// The port this benchmark server serves the app on.
final int benchmarkServerPort;

Expand Down Expand Up @@ -114,8 +118,13 @@ class BenchmarkServer {
'flutter',
'build',
'web',
if (useWasm) ...<String>[
'--wasm',
'--wasm-opt=debug',
'--omit-type-checks',
],
if (useCanvasKit) '--web-renderer=canvaskit',
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
if (useCanvasKit) '--dart-define=FLUTTER_WEB_USE_SKIA=true',
if (!treeShakeIcons) '--no-tree-shake-icons',
'--profile',
'-t',
Expand Down
2 changes: 1 addition & 1 deletion packages/web_benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: web_benchmarks
description: A benchmark harness for performance-testing Flutter apps in Chrome.
repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22
version: 0.1.0+11
version: 0.1.0+12

environment:
sdk: ">=3.2.0 <4.0.0"
Expand Down
10 changes: 10 additions & 0 deletions packages/web_benchmarks/testing/web_benchmarks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,29 @@ Future<void> main() async {
initialPage: 'index.html#about',
);
}, timeout: Timeout.none);

test('Can run a web benchmark with wasm', () async {
await _runBenchmarks(
benchmarkNames: <String>['simple'],
entryPoint: 'lib/benchmarks/runner_simple.dart',
useWasm: true,
);
}, timeout: Timeout.none);
}

Future<void> _runBenchmarks({
required List<String> benchmarkNames,
required String entryPoint,
String initialPage = defaultInitialPage,
bool useWasm = false,
}) async {
final BenchmarkResults taskResult = await serveWebBenchmark(
benchmarkAppDirectory: Directory('testing/test_app'),
entryPoint: entryPoint,
useCanvasKit: false,
treeShakeIcons: false,
initialPage: initialPage,
useWasm: useWasm,
);

for (final String benchmarkName in benchmarkNames) {
Expand Down