Skip to content

Commit 777cd0e

Browse files
committed
chore: update bench with binaryen
1 parent c2e6ce4 commit 777cd0e

File tree

7 files changed

+27
-9
lines changed

7 files changed

+27
-9
lines changed

docs/guide/llvm.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ Use following `.csproj` as a reference for enabling NativeAOT-LLVM with Bootshar
5555

5656
</Project>
5757
```
58+
59+
## Binaryen
60+
61+
Optionally, after publishing with NativeAOT-LLVM, you can further optimize the produced WASM using Binaryen:
62+
63+
1. Install the tool https://github.com/WebAssembly/binaryen
64+
2. Run `wasm-opt bin/bootsharp/bin/dotnet.native.wasm -O3 -o bin/bootsharp/bin/dotnet.native.wasm --all-features --strip-dwarf --strip-debug --vacuum`
65+
3. To optimize for size instead of speed, replace `-O3` with `-Oz`

samples/bench/bootsharp/readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
1. Install .NET https://dotnet.microsoft.com/en-us/download
2-
2. Run `dotnet publish`
2+
2. Install Binaryen https://github.com/WebAssembly/binaryen
3+
3. Run `dotnet publish`
4+
4. Run `wasm-opt bin/bootsharp/bin/dotnet.native.wasm -O3 -o bin/bootsharp/bin/dotnet.native.wasm --all-features --strip-dwarf --strip-debug --vacuum`
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
1. Install .NET https://dotnet.microsoft.com/en-us/download
2-
2. Run `dotnet publish`
2+
2. Install Binaryen https://github.com/WebAssembly/binaryen
3+
3. Run `dotnet publish`
4+
4. Run `wasm-opt bin/Release/net9.0-browser/browser-wasm/publish/dotnet.native.wasm -O3 -o bin/Release/net9.0-browser/browser-wasm/publish/dotnet.native.wasm --all-features --strip-dwarf --strip-debug --vacuum`
35

46
https://github.com/dotnet/runtime/issues/113979#issuecomment-2759220563

samples/bench/dotnet/readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
1. Install .NET https://dotnet.microsoft.com/en-us/download
2-
2. Run `dotnet publish`
2+
2. Install Binaryen https://github.com/WebAssembly/binaryen
3+
3. Run `dotnet publish`
4+
4. Run `wasm-opt bin/Release/net9.0/browser-wasm/publish/dotnet.native.wasm -O3 -o bin/Release/net9.0/browser-wasm/publish/dotnet.native.wasm --all-features --strip-dwarf --strip-debug --vacuum`

samples/bench/go/readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
1. Install Go https://go.dev/dl
2-
2. Copy `{GO_INSTALL_DIR}/lib/wasm/wasm_exec.js` to this folder
3-
3. Run `& { $env:GOOS="js"; $env:GOARCH="wasm"; go build -o main.wasm main.go }`
2+
2. Install Binaryen https://github.com/WebAssembly/binaryen
3+
3. Copy `{GO_INSTALL_DIR}/lib/wasm/wasm_exec.js` to this folder
4+
4. Run `& { $env:GOOS="js"; $env:GOARCH="wasm"; go build -o main.wasm main.go }`
5+
5. Run `wasm-opt main.wasm -O3 -o main.wasm --all-features --strip-dwarf --strip-debug --vacuum`

samples/bench/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ All results are relative to the Rust baseline (lower is better).
1616

1717
| | Rust | Zig | .NET LLVM | Bootsharp | .NET AOT | Go |
1818
|-------------|-------|-------|-----------|-----------|----------|---------|
19-
| Fibonacci | `1.0` | `1.0` | `1.0` | `1.0` | `1.7` | `3.8` |
20-
| Echo Number | `1.0` | `0.9` | `1.6` | `14.0` | `23.5` | `718.7` |
21-
| Echo Struct | `1.0` | `1.1` | `2.0` | `2.5` | `5.9` | `15.2` |
19+
| Fibonacci | `1.0` | `0.9` | `1.0` | `1.0` | `1.6` | `3.7` |
20+
| Echo Number | `1.0` | `0.8` | `1.6` | `14.0` | `23.5` | `718.7` |
21+
| Echo Struct | `1.0` | `1.0` | `2.0` | `2.5` | `5.9` | `15.2` |

samples/bench/zig/readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
1. Install Zig https://ziglang.org/download/
2-
2. Run `zig build -Doptimize=ReleaseFast`
2+
2. Install Binaryen https://github.com/WebAssembly/binaryen
3+
3. Run `zig build -Doptimize=ReleaseFast`
4+
4. Run `wasm-opt zig-out/bin/zig.wasm -O3 -o zig-out/bin/zig.wasm --all-features --strip-dwarf --strip-debug --vacuum`

0 commit comments

Comments
 (0)